Skip to content

Commit

Permalink
Fix fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
byme8 committed Jun 17, 2024
1 parent 1b01f75 commit 582d692
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void AnalyzeKeyOfUsages(
{
var keyOfs = parameters
.Where(o => o.RefKind != RefKind.Out)
.Select((o, i) => (Index: i, Type: (INamedTypeSymbol)o.Type))
.Select((o, i) => (Index: i, Type: o.Type as INamedTypeSymbol))
.Where(o => IsKeyOf(o.Type))
.ToArray();

Expand Down Expand Up @@ -87,19 +87,19 @@ expressionInvocation.Expression is IdentifierNameSyntax identifier &&
{
continue;
}

if (propertySymbol.Symbol is IParameterSymbol parameterSymbol &&
IsKeyOf(parameterSymbol.Type as INamedTypeSymbol))
{
continue;
}

if (propertySymbol.Symbol is IFieldSymbol fieldSymbol &&
IsKeyOf(fieldSymbol.Type as INamedTypeSymbol))
{
continue;
}

if (propertySymbol.Symbol is IPropertySymbol property &&
IsKeyOf(property.Type as INamedTypeSymbol))
{
Expand Down Expand Up @@ -132,10 +132,11 @@ expressionInvocation.Expression is IdentifierNameSyntax identifier &&
}
}

public static bool IsKeyOf(INamedTypeSymbol type)
=> type.ConstructedFrom.ToString().StartsWith("Apparatus.AOT.Reflection.KeyOf<");
public static bool IsKeyOf(INamedTypeSymbol? type)
=> type?.ConstructedFrom.ToString().StartsWith("Apparatus.AOT.Reflection.KeyOf<") ?? false;

public static string Version { get; } = typeof(KeyOfAnalyzer).Assembly.GetName().Version.ToString();

public static string CodeGenerationAttribute { get; } = $@"[System.CodeDom.Compiler.GeneratedCode(""AOT.Reflection"", ""{Version}"")]";
}
}

0 comments on commit 582d692

Please sign in to comment.