diff --git a/src/BlueWest.EfMethods/EfGeneratorContext.cs b/src/BlueWest.EfMethods/EfGeneratorContext.cs index 349acb6..174cefc 100644 --- a/src/BlueWest.EfMethods/EfGeneratorContext.cs +++ b/src/BlueWest.EfMethods/EfGeneratorContext.cs @@ -20,8 +20,7 @@ namespace BlueWest.EfMethods internal class EfGeneratorContext { private readonly List _ignoredNamespaces; - - + public ImmutableArray Diagnostics { get; private set; } public EfMethodsModel? Model { get; private set; } protected Compilation Compilation { get; } @@ -32,6 +31,8 @@ namespace BlueWest.EfMethods protected INamedTypeSymbol EfUpdateMethodsTypeSymbol { get; } protected INamedTypeSymbol EfAddMethodsTypeSymbol { get; } + protected INamedTypeSymbol EfGeneratorTypeSymbol { get; } + protected EfGeneratorContext( @@ -46,6 +47,7 @@ namespace BlueWest.EfMethods SourceGenerationOptions = sourceGenerationOptions; TypeSyntax = typeSyntax; EfUpdateMethodsTypeSymbol = compilation.GetTypeByMetadataNameOrThrow(EfUpdateMethodsAttributeSource.FullyQualifiedName); + EfGeneratorTypeSymbol = compilation.GetTypeByMetadataNameOrThrow(EfGeneratorAttributeSource.FullyQualifiedName); EfAddMethodsTypeSymbol = compilation.GetTypeByMetadataNameOrThrow(EfAddMethodsAttributeSource.FullyQualifiedName); AddUsingIfRequired(sourceGenerationOptions.SupportNullableStaticAnalysis, "System.Diagnostics.CodeAnalysis"); } @@ -259,13 +261,14 @@ namespace BlueWest.EfMethods // get containing class type information ClassDeclarationSyntax classDeclarationSyntax = (TypeSyntax as ClassDeclarationSyntax)!; + + var classDeclarationTypeInfo = semanticModel.GetTypeInfo(classDeclarationSyntax); // context name var dbContextName = classDeclarationSyntax.Identifier.ValueText; - var namespaceDeclaration = classDeclarationSyntax.Parent as NamespaceDeclarationSyntax; - var contextNamespace = namespaceDeclaration.Name.ToString(); + var contextNamespace = TypeSyntax.GetNamespace(); var contextTypeFullName = $"{contextNamespace}.{dbContextName}"; - + // handles different attributes @@ -600,8 +603,6 @@ namespace BlueWest.EfMethods private EfGetOneFromListModel ExtractEfGetOneFromListMethodsModel(MemberDeclarationSyntax uProperty, SemanticModel semanticModel, EfEntityDataModel entityDataModel) { - //SpinWait.SpinUntil(() => Debugger.IsAttached); - var efTypeofSymbols = GetEntityTypeSymbol(uProperty, EfGetOneFromListAttributeSource.AttributeName, semanticModel); var attributeSymbol = uProperty.GetAttribute(EfGetOneFromListAttributeSource.AttributeName); var keyPropertyName = ExtractNameOfMemberName(uProperty, EfGetOneFromListAttributeSource.AttributeName); diff --git a/src/BlueWest.EfMethods/EfMethodsGenerator.cs b/src/BlueWest.EfMethods/EfMethodsGenerator.cs index 4cf7aa0..fe1b766 100644 --- a/src/BlueWest.EfMethods/EfMethodsGenerator.cs +++ b/src/BlueWest.EfMethods/EfMethodsGenerator.cs @@ -27,6 +27,9 @@ namespace BlueWest.EfMethods /// public void Execute(GeneratorExecutionContext context) { + + //SpinWait.SpinUntil(() => Debugger.IsAttached); + try { var options = SourceGenerationOptions.From(context);