Skip to content

Commit 7b7135e

Browse files
committed
.
1 parent 52ed245 commit 7b7135e

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

src/GraphQL.EntityFramework.Analyzers/FieldBuilderResolveAnalyzer.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@ bool IsInEfGraphType(SyntaxNode node, SemanticModel semanticModel)
164164
bool AccessesNavigationProperties(LambdaExpressionSyntax lambda, SemanticModel semanticModel)
165165
{
166166
var body = lambda.Body;
167-
if (body == null)
168-
{
169-
return false;
170-
}
171167

172168
// Find all member access expressions in the lambda
173169
var memberAccesses = body.DescendantNodesAndSelf()
@@ -209,19 +205,16 @@ bool IsContextSourceAccess(MemberAccessExpressionSyntax memberAccess, out Member
209205
MemberAccessExpressionSyntax? sourceAccess = null;
210206

211207
// Walk up the chain to find context.Source
212-
while (current != null)
208+
while (true)
213209
{
214-
if (current.Expression is MemberAccessExpressionSyntax innerAccess &&
215-
innerAccess.Name.Identifier.Text == "Source" &&
216-
innerAccess.Expression is IdentifierNameSyntax identifier &&
210+
if (current.Expression is MemberAccessExpressionSyntax { Name.Identifier.Text: "Source", Expression: IdentifierNameSyntax identifier } &&
217211
(identifier.Identifier.Text == "context" || identifier.Identifier.Text == "ctx"))
218212
{
219213
sourceAccess = current;
220214
break;
221215
}
222216

223-
if (current.Expression is IdentifierNameSyntax id &&
224-
id.Identifier.Text == "Source")
217+
if (current.Expression is IdentifierNameSyntax { Identifier.Text: "Source" })
225218
{
226219
// This might be a simplified lambda like: Source => Source.Property
227220
sourceAccess = current;
@@ -282,7 +275,7 @@ bool IsSafeProperty(IPropertySymbol propertySymbol)
282275
return false;
283276
}
284277

285-
bool IsPrimaryKeyProperty(IPropertySymbol propertySymbol)
278+
static bool IsPrimaryKeyProperty(IPropertySymbol propertySymbol)
286279
{
287280
var name = propertySymbol.Name;
288281

@@ -314,7 +307,7 @@ bool IsPrimaryKeyProperty(IPropertySymbol propertySymbol)
314307
return false;
315308
}
316309

317-
bool IsForeignKeyProperty(IPropertySymbol propertySymbol)
310+
static bool IsForeignKeyProperty(IPropertySymbol propertySymbol)
318311
{
319312
var name = propertySymbol.Name;
320313
var type = propertySymbol.Type;
@@ -334,7 +327,7 @@ bool IsForeignKeyProperty(IPropertySymbol propertySymbol)
334327
// Check if the type is a scalar type suitable for FK (int, long, Guid, etc.)
335328
// Unwrap nullable
336329
var underlyingType = type;
337-
if (type is INamedTypeSymbol namedType && namedType.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T)
330+
if (type is INamedTypeSymbol { OriginalDefinition.SpecialType: SpecialType.System_Nullable_T } namedType)
338331
{
339332
underlyingType = namedType.TypeArguments[0];
340333
}

src/GraphQL.EntityFramework/GraphApi/FieldBuilderExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static FieldBuilder<TSource, TReturn> Resolve<TDbContext, TSource, TRetur
6969
}
7070
catch (Exception exception)
7171
{
72-
throw new Exception(
72+
throw new(
7373
$"""
7474
Failed to execute projection-based resolve for field `{field.Name}`
7575
TSource: {typeof(TSource).FullName}
@@ -155,7 +155,7 @@ public static FieldBuilder<TSource, TReturn> ResolveAsync<TDbContext, TSource, T
155155
}
156156
catch (Exception exception)
157157
{
158-
throw new Exception(
158+
throw new(
159159
$"""
160160
Failed to execute projection-based async resolve for field `{field.Name}`
161161
TSource: {typeof(TSource).FullName}

0 commit comments

Comments
 (0)