diff --git a/src/DynamoDBGenerator.SourceGenerator/Constants.cs b/src/DynamoDBGenerator.SourceGenerator/Constants.cs index 32507017..87cf7dc7 100644 --- a/src/DynamoDBGenerator.SourceGenerator/Constants.cs +++ b/src/DynamoDBGenerator.SourceGenerator/Constants.cs @@ -33,7 +33,7 @@ public static class ConversionStrategy } public const string AssemblyName = "DynamoDBGenerator"; - public const string DynamoDbDocumentPropertyFullname = $"{Namespace.AttributesFullName}.{Attribute.DynamoDBMarshaller}"; + public const string DynamoDBMarshallerFullname = $"{Namespace.AttributesFullName}.{Attribute.DynamoDBMarshaller}"; public const string DynamoDBConverterFullName = $"{AssemblyName}.{Namespace.Options}.{Converter.AttributeValueConverters}"; diff --git a/src/DynamoDBGenerator.SourceGenerator/DynamoDBDMarshallerEntry.cs b/src/DynamoDBGenerator.SourceGenerator/DynamoDBDMarshaller.cs similarity index 96% rename from src/DynamoDBGenerator.SourceGenerator/DynamoDBDMarshallerEntry.cs rename to src/DynamoDBGenerator.SourceGenerator/DynamoDBDMarshaller.cs index 8074ab39..67a782fd 100644 --- a/src/DynamoDBGenerator.SourceGenerator/DynamoDBDMarshallerEntry.cs +++ b/src/DynamoDBGenerator.SourceGenerator/DynamoDBDMarshaller.cs @@ -10,13 +10,13 @@ namespace DynamoDBGenerator.SourceGenerator; [Generator] // ReSharper disable once InconsistentNaming -public class DynamoDBDMarshallerEntry : IIncrementalGenerator +public class DynamoDBDMarshaller : IIncrementalGenerator { public void Initialize(IncrementalGeneratorInitializationContext context) { var updateClassDeclarations = context.SyntaxProvider .ForAttributeWithMetadataName( - Constants.DynamoDBGenerator.DynamoDbDocumentPropertyFullname, + Constants.DynamoDBGenerator.DynamoDBMarshallerFullname, (n, _) => n is ClassDeclarationSyntax or RecordDeclarationSyntax or StructDeclarationSyntax, (c, _) => c.TargetNode ); @@ -74,12 +74,11 @@ private static IEnumerable CreateFileContent(INamedTypeSymbol type, Comp throw new NotImplementedException( $"Generate accessibility of '{type.DeclaredAccessibility}' on '{type.ToDisplayParts()}' only '{type.DeclaredAccessibility == Accessibility.Public}' is supported." ); - var @static = type.IsStatic ? "static " : null; - var (options, args) = CreateArguments(type, compilation); - var classContent = - $"public {@static}{typeType} {type.Name}".CreateScope(DynamoDbMarshaller.CreateRepository(args, options)); + var classContent = $"public {(type.IsStatic ? "static " : null)}{typeType} {type.Name}" + .CreateScope(MarshallerFactory.CreateRepository(args, options)); + var content = type.ContainingNamespace.IsGlobalNamespace ? classContent : $"namespace {type.ContainingNamespace.ToDisplayString()}".CreateScope(classContent); diff --git a/src/DynamoDBGenerator.SourceGenerator/DynamoDbMarshaller.cs b/src/DynamoDBGenerator.SourceGenerator/MarshallerFactory.cs similarity index 98% rename from src/DynamoDBGenerator.SourceGenerator/DynamoDbMarshaller.cs rename to src/DynamoDBGenerator.SourceGenerator/MarshallerFactory.cs index cafb91fe..875de737 100644 --- a/src/DynamoDBGenerator.SourceGenerator/DynamoDbMarshaller.cs +++ b/src/DynamoDBGenerator.SourceGenerator/MarshallerFactory.cs @@ -5,7 +5,7 @@ using static DynamoDBGenerator.SourceGenerator.Constants.DynamoDBGenerator.Marshaller; namespace DynamoDBGenerator.SourceGenerator; -public static class DynamoDbMarshaller +public static class MarshallerFactory { private static IEnumerable CreateImplementations(IEnumerable arguments, MarshallerOptions options)