Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ".g.cs" extension for all generated files #284

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
Expand All @@ -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));
}
});

Expand All @@ -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));
}
});
}
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));
});
}
}