Skip to content

Commit

Permalink
Change generated.cs -> g.cs to make it work with coverlet [coverlet-c…
Browse files Browse the repository at this point in the history
  • Loading branch information
C0nquistadore committed Oct 20, 2022
1 parent 6463dda commit 06223dc
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/PhoneBox.Generators/SignalRHubGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private static void RegisterPostInitializationOutput(IncrementalGeneratorPostIni
if (extensionIndex < 0)
extensionIndex = fileName.Length;

fileName = fileName.Insert(extensionIndex, ".generated");
fileName = fileName.Insert(extensionIndex, ".g");

string content;
using (Stream stream = ThisAssembly.GetManifestResourceStream(resourceName)!)
Expand All @@ -134,7 +134,7 @@ private static void RegisterPostInitializationOutput(IncrementalGeneratorPostIni

private static void AddImplementation(SourceProductionContext context, string className, string interfaceName, string @namespace, string? contractNamespace)
{
string fileName = $"{className}.generated.cs";
string fileName = $"{className}.g.cs";
string content = $@"{GeneratedCodeHeader}
namespace {@namespace}
Expand All @@ -148,7 +148,7 @@ public partial class {className} : global::Microsoft.AspNetCore.SignalR.Hub<glob

private static void AddInterface(SourceProductionContext context, string interfaceName, string @namespace, string? contractNamespace, IEnumerable<OpenApiHubMethod> methods)
{
string fileName = $"{interfaceName}.generated.cs";
string fileName = $"{interfaceName}.g.cs";
string methodsStr = String.Join(Environment.NewLine, methods.Select(x => GenerateInterfaceMethod(x, contractNamespace ?? @namespace)));
string content = $@"{GeneratedCodeHeader}
Expand All @@ -166,7 +166,7 @@ public interface {interfaceName}
private static void AddModel(SourceProductionContext context, string @namespace, OpenApiHubModel model)
{
string content = GenerateModel(@namespace, model);
context.AddSource($"{model.Name}.generated.cs", content);
context.AddSource($"{model.Name}.g.cs", content);
}

private static string GenerateModel(string @namespace, OpenApiHubModel model)
Expand Down Expand Up @@ -234,7 +234,7 @@ internal static class HubEndpointRouteBuilderExtensions
{methodsStr}
}}
}}";
context.AddSource("HubEndpointRouteBuilderExtensions.generated.cs", content);
context.AddSource("HubEndpointRouteBuilderExtensions.g.cs", content);
}

private static string GenerateInterfaceMethod(OpenApiHubMethod method, string @namespace)
Expand Down
22 changes: 11 additions & 11 deletions tests/PhoneBox.Generators.Tests/GeneratorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public void SignalRHubGenerator_Implementation()
, assertOutputs: true
, expectedFiles: new[]
{
"SignalRHubGenerationAttribute.generated.cs"
, "SignalRHubGenerationOutputs.generated.cs"
, "TelephonyHub.generated.cs"
, "HubEndpointRouteBuilderExtensions.generated.cs"
"SignalRHubGenerationAttribute.g.cs"
, "SignalRHubGenerationOutputs.g.cs"
, "TelephonyHub.g.cs"
, "HubEndpointRouteBuilderExtensions.g.cs"
}
, MetadataReference.CreateFromFile(typeof(Hub).Assembly.Location)
, MetadataReference.CreateFromFile(typeof(HubEndpointConventionBuilder).Assembly.Location)
Expand All @@ -63,13 +63,13 @@ public void SignalRHubGenerator_Implementation()
, assertOutputs: assertOutputs
, expectedFiles: new[]
{
"SignalRHubGenerationAttribute.generated.cs"
, "SignalRHubGenerationOutputs.generated.cs"
, "CallConnectedEvent.generated.cs"
, "CallDisconnectedEvent.generated.cs"
, "CallState.generated.cs"
, "CallHangUpReason.generated.cs"
, "ITelephonyHub.generated.cs"
"SignalRHubGenerationAttribute.g.cs"
, "SignalRHubGenerationOutputs.g.cs"
, "CallConnectedEvent.g.cs"
, "CallDisconnectedEvent.g.cs"
, "CallState.g.cs"
, "CallHangUpReason.g.cs"
, "ITelephonyHub.g.cs"
}
);

Expand Down

0 comments on commit 06223dc

Please sign in to comment.