From 8157b745bc7209794ab775bb8aaa45497dfa9682 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 30 May 2022 18:25:04 +0200 Subject: [PATCH] Use ".g.cs" extension for all generated files --- .../Attributes/NullabilityAttributesGenerator.cs | 4 ++-- .../ComponentModel/ObservablePropertyGenerator.cs | 6 +++--- .../ObservableValidatorValidateAllPropertiesGenerator.cs | 4 ++-- .../ComponentModel/TransitiveMembersGenerator.cs | 2 +- .../Input/ICommandGenerator.cs | 2 +- .../Messaging/IMessengerRegisterAllGenerator.cs | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CommunityToolkit.Mvvm.SourceGenerators/Attributes/NullabilityAttributesGenerator.cs b/CommunityToolkit.Mvvm.SourceGenerators/Attributes/NullabilityAttributesGenerator.cs index 147e9a95e..cfb540200 100644 --- a/CommunityToolkit.Mvvm.SourceGenerators/Attributes/NullabilityAttributesGenerator.cs +++ b/CommunityToolkit.Mvvm.SourceGenerators/Attributes/NullabilityAttributesGenerator.cs @@ -44,7 +44,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { string source = LoadAttributeSourceWithMetadataName(NotNullAttributeMetadataName); - context.AddSource(NotNullAttributeMetadataName, source); + context.AddSource($"{NotNullAttributeMetadataName}.g.cs", source); }); // Check whether [NotNullIfNotNull] is not available @@ -57,7 +57,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { string source = LoadAttributeSourceWithMetadataName(NotNullIfNotNullAttributeMetadataName); - context.AddSource(NotNullIfNotNullAttributeMetadataName, source); + context.AddSource($"{NotNullIfNotNullAttributeMetadataName}.g.cs", source); }); } diff --git a/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.cs b/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.cs index 2fa8bbe2e..b6c298e5c 100644 --- a/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.cs +++ b/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservablePropertyGenerator.cs @@ -94,7 +94,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) // Insert all members into the same partial type declaration CompilationUnitSyntax compilationUnit = item.Hierarchy.GetCompilationUnit(memberDeclarations); - context.AddSource(item.Hierarchy.FilenameHint, compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Hierarchy.FilenameHint}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Gather all property changing names @@ -112,7 +112,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) if (compilationUnit is not null) { - context.AddSource("__KnownINotifyPropertyChangingArgs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource("__KnownINotifyPropertyChangingArgs.g.cs", compilationUnit.GetText(Encoding.UTF8)); } }); @@ -131,7 +131,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) if (compilationUnit is not null) { - context.AddSource("__KnownINotifyPropertyChangedArgs", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource("__KnownINotifyPropertyChangedArgs.g.cs", compilationUnit.GetText(Encoding.UTF8)); } }); } diff --git a/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservableValidatorValidateAllPropertiesGenerator.cs b/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservableValidatorValidateAllPropertiesGenerator.cs index 6273285e6..42029748b 100644 --- a/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservableValidatorValidateAllPropertiesGenerator.cs +++ b/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/ObservableValidatorValidateAllPropertiesGenerator.cs @@ -59,7 +59,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { CompilationUnitSyntax compilationUnit = Execute.GetSyntax(item); - context.AddSource("__ObservableValidatorExtensions", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource("__ObservableValidatorExtensions.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Generate the class with all validation methods @@ -67,7 +67,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { CompilationUnitSyntax compilationUnit = Execute.GetSyntax(item); - context.AddSource(item.FilenameHint, compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.FilenameHint}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); } } diff --git a/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/TransitiveMembersGenerator.cs b/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/TransitiveMembersGenerator.cs index 17316ab35..82bdfbd87 100644 --- a/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/TransitiveMembersGenerator.cs +++ b/CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/TransitiveMembersGenerator.cs @@ -122,7 +122,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) ImmutableArray filteredMemberDeclarations = FilterDeclaredMembers(item.Info, sourceMemberDeclarations); CompilationUnitSyntax compilationUnit = item.Hierarchy.GetCompilationUnit(filteredMemberDeclarations, this.classDeclaration.BaseList); - context.AddSource(item.Hierarchy.FilenameHint, compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Hierarchy.FilenameHint}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); } diff --git a/CommunityToolkit.Mvvm.SourceGenerators/Input/ICommandGenerator.cs b/CommunityToolkit.Mvvm.SourceGenerators/Input/ICommandGenerator.cs index 0cc82aa90..0d9f7a6c5 100644 --- a/CommunityToolkit.Mvvm.SourceGenerators/Input/ICommandGenerator.cs +++ b/CommunityToolkit.Mvvm.SourceGenerators/Input/ICommandGenerator.cs @@ -69,7 +69,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) ImmutableArray memberDeclarations = Execute.GetSyntax(item.Info); CompilationUnitSyntax compilationUnit = item.Hierarchy.GetCompilationUnit(memberDeclarations); - context.AddSource($"{item.Hierarchy.FilenameHint}.{item.Info.MethodName}", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.Hierarchy.FilenameHint}.{item.Info.MethodName}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); } } diff --git a/CommunityToolkit.Mvvm.SourceGenerators/Messaging/IMessengerRegisterAllGenerator.cs b/CommunityToolkit.Mvvm.SourceGenerators/Messaging/IMessengerRegisterAllGenerator.cs index b3029c2db..dcb5f6633 100644 --- a/CommunityToolkit.Mvvm.SourceGenerators/Messaging/IMessengerRegisterAllGenerator.cs +++ b/CommunityToolkit.Mvvm.SourceGenerators/Messaging/IMessengerRegisterAllGenerator.cs @@ -67,7 +67,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { CompilationUnitSyntax compilationUnit = Execute.GetSyntax(item); - context.AddSource("__IMessengerExtensions", compilationUnit.GetText(Encoding.UTF8)); + context.AddSource("__IMessengerExtensions.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); // Generate the class with all registration methods @@ -75,7 +75,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { CompilationUnitSyntax compilationUnit = Execute.GetSyntax(item); - context.AddSource(item.FilenameHint, compilationUnit.GetText(Encoding.UTF8)); + context.AddSource($"{item.FilenameHint}.g.cs", compilationUnit.GetText(Encoding.UTF8)); }); } }