Skip to content

Commit

Permalink
Merge pull request #284 from CommunityToolkit/dev/use-g-cs-generated-…
Browse files Browse the repository at this point in the history
…extension

Use ".g.cs" extension for all generated files
  • Loading branch information
Sergio0694 authored Jun 1, 2022
2 parents cbafd72 + 8157b74 commit 77b39b6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -57,7 +57,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
{
string source = LoadAttributeSourceWithMetadataName(NotNullIfNotNullAttributeMetadataName);

context.AddSource(NotNullIfNotNullAttributeMetadataName, source);
context.AddSource($"{NotNullIfNotNullAttributeMetadataName}.g.cs", source);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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
Expand All @@ -113,7 +113,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));
}
});

Expand All @@ -132,7 +132,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));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ 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
context.RegisterImplementationSourceOutput(validationInfo, static (context, item) =>
{
CompilationUnitSyntax compilationUnit = Execute.GetSyntax(item);

context.AddSource(item.FilenameHint, compilationUnit.GetText(Encoding.UTF8));
context.AddSource($"{item.FilenameHint}.g.cs", compilationUnit.GetText(Encoding.UTF8));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
ImmutableArray<MemberDeclarationSyntax> 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));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
ImmutableArray<MemberDeclarationSyntax> 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));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ 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
context.RegisterImplementationSourceOutput(recipientInfo, static (context, item) =>
{
CompilationUnitSyntax compilationUnit = Execute.GetSyntax(item);

context.AddSource(item.FilenameHint, compilationUnit.GetText(Encoding.UTF8));
context.AddSource($"{item.FilenameHint}.g.cs", compilationUnit.GetText(Encoding.UTF8));
});
}
}

0 comments on commit 77b39b6

Please sign in to comment.