Skip to content

Commit d6f5397

Browse files
committed
Restructured projects
1 parent 21ede44 commit d6f5397

30 files changed

+117
-103
lines changed

src/GreenDonut/GreenDonut.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenDonut", "src\Core\Gree
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenDonut.Tests", "test\Core.Tests\GreenDonut.Tests.csproj", "{1F96BB47-B053-4E9C-865A-5B6FB613CB0D}"
1919
EndProject
20+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenDonut.Data.Primitives", "src\Data.Primitives\GreenDonut.Data.Primitives.csproj", "{D30715C8-C763-4B36-B502-2991EBF76758}"
21+
EndProject
2022
Global
2123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2224
Debug|Any CPU = Debug|Any CPU
@@ -31,13 +33,18 @@ Global
3133
{1F96BB47-B053-4E9C-865A-5B6FB613CB0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
3234
{1F96BB47-B053-4E9C-865A-5B6FB613CB0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
3335
{1F96BB47-B053-4E9C-865A-5B6FB613CB0D}.Release|Any CPU.Build.0 = Release|Any CPU
36+
{D30715C8-C763-4B36-B502-2991EBF76758}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37+
{D30715C8-C763-4B36-B502-2991EBF76758}.Debug|Any CPU.Build.0 = Debug|Any CPU
38+
{D30715C8-C763-4B36-B502-2991EBF76758}.Release|Any CPU.ActiveCfg = Release|Any CPU
39+
{D30715C8-C763-4B36-B502-2991EBF76758}.Release|Any CPU.Build.0 = Release|Any CPU
3440
EndGlobalSection
3541
GlobalSection(SolutionProperties) = preSolution
3642
HideSolutionNode = FALSE
3743
EndGlobalSection
3844
GlobalSection(NestedProjects) = preSolution
3945
{FD764A95-F950-40F3-9577-E3168BBC330D} = {251185F7-7E3B-4BB3-B500-56C90564EE8C}
4046
{1F96BB47-B053-4E9C-865A-5B6FB613CB0D} = {A829F8F0-4468-405C-8A26-3E5921F7324A}
47+
{D30715C8-C763-4B36-B502-2991EBF76758} = {251185F7-7E3B-4BB3-B500-56C90564EE8C}
4148
EndGlobalSection
4249
GlobalSection(ExtensibilityGlobals) = postSolution
4350
SolutionGuid = {CC1769AF-BDF5-4EF2-AED8-1719C180F131}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
2+
3+
<PropertyGroup>
4+
<PackageId>GreenDonut.Data.Primitives</PackageId>
5+
<AssemblyName>GreenDonut.Data.Primitives</AssemblyName>
6+
<RootNamespace>GreenDonut.Data</RootNamespace>
7+
<Description>This package contains the basic building blocks of the DataLoader linq query integration.</Description>
8+
</PropertyGroup>
9+
10+
</Project>

src/HotChocolate/Primitives/src/Primitives.Data/ISortBy.cs renamed to src/GreenDonut/src/Data.Primitives/ISortBy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Linq.Expressions;
22

3-
namespace HotChocolate.Data;
3+
namespace GreenDonut.Data;
44

55
/// <summary>
66
/// Represents a sort operation on a field.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Linq.Expressions;
2+
3+
namespace GreenDonut.Data;
4+
5+
/// <summary>
6+
/// Represents the context for constructing queries against a data source for <typeparamref name="TEntity"/>.
7+
/// This record contains the projection (selector), filtering (predicate), and sorting instructions
8+
/// (<see cref="SortDefinition{TEntity}"/>) for building a query.
9+
/// </summary>
10+
/// <typeparam name="TEntity">
11+
/// The entity type associated with the query context.
12+
/// </typeparam>
13+
/// <param name="Selector">
14+
/// An expression that defines what data shall be selected from <typeparamref name="TEntity"/>.
15+
/// </param>
16+
/// <param name="Predicate">
17+
/// An expression that defines the filtering condition for <typeparamref name="TEntity"/>.
18+
/// </param>
19+
/// <param name="Sorting">
20+
/// The sorting instructions (see <see cref="SortDefinition{TEntity}"/>) for <typeparamref name="TEntity"/>.
21+
/// </param>
22+
public record QueryContext<TEntity>(
23+
Expression<Func<TEntity, TEntity>>? Selector = null,
24+
Expression<Func<TEntity, bool>>? Predicate = null,
25+
SortDefinition<TEntity>? Sorting = null);

src/HotChocolate/Primitives/src/Primitives.Data/SortBy.cs renamed to src/GreenDonut/src/Data.Primitives/SortBy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Linq.Expressions;
22

3-
namespace HotChocolate.Data;
3+
namespace GreenDonut.Data;
44

55
/// <summary>
66
/// Represents a sort operation on a field.

src/HotChocolate/Primitives/src/Primitives.Data/SortDefinition.cs renamed to src/GreenDonut/src/Data.Primitives/SortDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Collections.Immutable;
22

3-
namespace HotChocolate.Data;
3+
namespace GreenDonut.Data;
44

55
/// <summary>
66
/// Represents all sort operations applied to an entity type.

src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/ResolverFileBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,15 +715,15 @@ private void AddResolverArguments(Resolver resolver, IMethodSymbol resolverMetho
715715
ToFullyQualifiedString(parameter.Type, resolverMethod, typeLookup));
716716
break;
717717

718-
case ResolverParameterKind.DataContext:
718+
case ResolverParameterKind.QueryContext:
719719
var entityType = parameter.TypeParameters[0].ToFullyQualified();
720720
_writer.WriteIndentedLine("var args{0}_selection = context.Selection;", i);
721721
_writer.WriteIndentedLine("var args{0}_filter = context.GetFilterContext();", i);
722722
_writer.WriteIndentedLine("var args{0}_sorting = context.GetSortingContext();", i);
723723
_writer.WriteIndentedLine(
724724
"var args{0} = new global::{1}<{2}>(",
725725
i,
726-
WellKnownTypes.DataContext,
726+
WellKnownTypes.QueryContext,
727727
entityType);
728728
using (_writer.IncreaseIndent())
729729
{

src/HotChocolate/Core/src/Types.Analyzers/Helpers/DataLoaderAttributeHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static bool IsDataLoaderGroupAttribute(INamedTypeSymbol? attributeClass)
6969
{
7070
foreach (var attributeData in parameter.GetAttributes())
7171
{
72-
if (!IsTypeName(attributeData.AttributeClass, "GreenDonut", "DataLoaderStateAttribute"))
72+
if (!attributeData.AttributeClass.IsOrInheritsFrom("GreenDonut.DataLoaderStateAttribute"))
7373
{
7474
continue;
7575
}

src/HotChocolate/Core/src/Types.Analyzers/Helpers/SymbolExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ public static bool IsSetState(this IParameterSymbol parameter)
110110
return false;
111111
}
112112

113-
public static bool IsDataContext(this IParameterSymbol parameter)
113+
public static bool IsQueryContext(this IParameterSymbol parameter)
114114
{
115115
if (parameter.Type is INamedTypeSymbol namedTypeSymbol
116116
&& namedTypeSymbol is { IsGenericType: true, TypeArguments.Length: 1 }
117-
&& namedTypeSymbol.ToDisplayString().StartsWith(WellKnownTypes.DataContextGeneric))
117+
&& namedTypeSymbol.ToDisplayString().StartsWith(WellKnownTypes.QueryContextGeneric))
118118
{
119119
return true;
120120
}
@@ -130,7 +130,7 @@ public static bool IsGlobalState(
130130

131131
foreach (var attributeData in parameter.GetAttributes())
132132
{
133-
if (IsOrInheritsFromAttribute(attributeData.AttributeClass, "HotChocolate.GlobalStateAttribute"))
133+
if (IsOrInheritsFrom(attributeData.AttributeClass, "HotChocolate.GlobalStateAttribute"))
134134
{
135135
if (attributeData.ConstructorArguments.Length == 1 &&
136136
attributeData.ConstructorArguments[0].Kind == TypedConstantKind.Primitive &&
@@ -165,7 +165,7 @@ public static bool IsScopedState(
165165

166166
foreach (var attributeData in parameter.GetAttributes())
167167
{
168-
if (IsOrInheritsFromAttribute(attributeData.AttributeClass, "HotChocolate.ScopedStateAttribute"))
168+
if (IsOrInheritsFrom(attributeData.AttributeClass, "HotChocolate.ScopedStateAttribute"))
169169
{
170170
if (attributeData.ConstructorArguments.Length == 1 &&
171171
attributeData.ConstructorArguments[0].Kind == TypedConstantKind.Primitive &&
@@ -200,7 +200,7 @@ public static bool IsLocalState(
200200

201201
foreach (var attributeData in parameter.GetAttributes())
202202
{
203-
if (IsOrInheritsFromAttribute(attributeData.AttributeClass, "HotChocolate.LocalStateAttribute"))
203+
if (IsOrInheritsFrom(attributeData.AttributeClass, "HotChocolate.LocalStateAttribute"))
204204
{
205205
if (attributeData.ConstructorArguments.Length == 1 &&
206206
attributeData.ConstructorArguments[0].Kind == TypedConstantKind.Primitive &&
@@ -492,7 +492,7 @@ private static bool IsPostProcessorAttribute(INamedTypeSymbol? attributeClass)
492492
return false;
493493
}
494494

495-
private static bool IsOrInheritsFromAttribute(ITypeSymbol? attributeClass, string fullTypeName)
495+
public static bool IsOrInheritsFrom(this ITypeSymbol? attributeClass, string fullTypeName)
496496
{
497497
var current = attributeClass;
498498

src/HotChocolate/Core/src/Types.Analyzers/Inspectors/DataLoaderInspector.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Diagnostics.CodeAnalysis;
22
using HotChocolate.Types.Analyzers.Filters;
3-
using HotChocolate.Types.Analyzers.Helpers;
43
using HotChocolate.Types.Analyzers.Models;
54
using Microsoft.CodeAnalysis;
65
using Microsoft.CodeAnalysis.CSharp;

0 commit comments

Comments
 (0)