From 62b322a494d69c51da1a9eb3aa2098b23d4131ff Mon Sep 17 00:00:00 2001 From: Tommy Date: Sat, 1 Oct 2022 21:16:56 +0200 Subject: [PATCH] Improve source generator output --- .../SignalRHubGenerationAttribute.cs | 12 +- .../SignalRHubGenerationOutputs.cs | 6 +- .../PhoneBox.Generators.csproj | 1 + .../PhoneBox.Generators.csproj.DotSettings | 3 +- .../SignalRHubGenerator.cs | 176 ++++++++++++------ .../Utilities/Annotation.cs | 29 +++ .../GeneratorTest.cs | 2 +- .../PhoneBox.Generators.Tests.csproj | 2 +- ...oneBox.Generators.Tests.csproj.DotSettings | 3 +- .../Resources/CallConnectedEvent.generated.cs | 12 ++ .../CallDisconnectedEvent.generated.cs | 12 ++ .../Resources/CallHangUpReason.generated.cs | 10 + .../Resources/CallState.generated.cs | 10 + ...ndpointRouteBuilderExtensions.generated.cs | 15 +- .../Resources/ITelephonyHub.generated.cs | 14 +- ...SignalRHubGenerationAttribute.generated.cs | 20 +- .../SignalRHubGenerationOutputs.generated.cs | 12 +- .../Resources/TelephonyHub.generated.cs | 12 +- 18 files changed, 268 insertions(+), 83 deletions(-) create mode 100644 src/PhoneBox.Generators/Utilities/Annotation.cs diff --git a/src/PhoneBox.Generators/EmbeddedSources/SignalRHubGenerationAttribute.cs b/src/PhoneBox.Generators/EmbeddedSources/SignalRHubGenerationAttribute.cs index 35e23da..3d308a7 100644 --- a/src/PhoneBox.Generators/EmbeddedSources/SignalRHubGenerationAttribute.cs +++ b/src/PhoneBox.Generators/EmbeddedSources/SignalRHubGenerationAttribute.cs @@ -1,13 +1,11 @@ -using System; - -namespace PhoneBox.Generators +namespace PhoneBox.Generators { - [AttributeUsage(AttributeTargets.Assembly)] - internal sealed class SignalRHubGenerationAttribute : Attribute + [global::System.AttributeUsage(global::System.AttributeTargets.Assembly)] + internal sealed class SignalRHubGenerationAttribute : global::System.Attribute { - public SignalRHubGenerationOutputs OutputFilter { get; } + public global::PhoneBox.Generators.SignalRHubGenerationOutputs OutputFilter { get; } - public SignalRHubGenerationAttribute(SignalRHubGenerationOutputs outputFilter = SignalRHubGenerationOutputs.All) + public SignalRHubGenerationAttribute(global::PhoneBox.Generators.SignalRHubGenerationOutputs outputFilter = global::PhoneBox.Generators.SignalRHubGenerationOutputs.All) { OutputFilter = outputFilter; } diff --git a/src/PhoneBox.Generators/EmbeddedSources/SignalRHubGenerationOutputs.cs b/src/PhoneBox.Generators/EmbeddedSources/SignalRHubGenerationOutputs.cs index 04a96e8..6ce3cd0 100644 --- a/src/PhoneBox.Generators/EmbeddedSources/SignalRHubGenerationOutputs.cs +++ b/src/PhoneBox.Generators/EmbeddedSources/SignalRHubGenerationOutputs.cs @@ -1,8 +1,6 @@ -using System; - -namespace PhoneBox.Generators +namespace PhoneBox.Generators { - [Flags] + [global::System.Flags] internal enum SignalRHubGenerationOutputs { None = 0, diff --git a/src/PhoneBox.Generators/PhoneBox.Generators.csproj b/src/PhoneBox.Generators/PhoneBox.Generators.csproj index a5f4e77..6121246 100644 --- a/src/PhoneBox.Generators/PhoneBox.Generators.csproj +++ b/src/PhoneBox.Generators/PhoneBox.Generators.csproj @@ -7,6 +7,7 @@ + diff --git a/src/PhoneBox.Generators/PhoneBox.Generators.csproj.DotSettings b/src/PhoneBox.Generators/PhoneBox.Generators.csproj.DotSettings index 0b3e459..2209b3c 100644 --- a/src/PhoneBox.Generators/PhoneBox.Generators.csproj.DotSettings +++ b/src/PhoneBox.Generators/PhoneBox.Generators.csproj.DotSettings @@ -1,3 +1,4 @@  Library - True \ No newline at end of file + True + True \ No newline at end of file diff --git a/src/PhoneBox.Generators/SignalRHubGenerator.cs b/src/PhoneBox.Generators/SignalRHubGenerator.cs index fe40e2f..0110fca 100644 --- a/src/PhoneBox.Generators/SignalRHubGenerator.cs +++ b/src/PhoneBox.Generators/SignalRHubGenerator.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Text; using System.Threading; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -22,8 +23,18 @@ public sealed class SignalRHubGenerator : IIncrementalGenerator { private static readonly Assembly ThisAssembly = typeof(SignalRHubGenerator).Assembly; private static readonly string AttributeTypeName = typeof(SignalRHubGenerationAttribute).FullName; + private static readonly string DefaultAnnotationsStr = ComputeDefaultAnnotationsStr(); + private static readonly string GeneratedCodeAnnotationStr = ComputeGeneratedCodeAnnotationStr(); private const string EmbeddedSourcePrefix = $"{nameof(PhoneBox)}.{nameof(Generators)}.EmbeddedSources"; private const string EnumVarNamesExtension = "x-enum-varnames"; + private const string GeneratedCodeHeader = @"//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------"; public void Initialize(IncrementalGeneratorInitializationContext context) { @@ -60,7 +71,7 @@ private static void CollectSources(SourceProductionContext context, OpenApiDocum ReportOpenApiErrors(context, container.Path, container.Diagnostic); - string? @namespace = configuredNamespace ?? rootNamespace ?? assemblyName; + string @namespace = configuredNamespace ?? rootNamespace ?? assemblyName ?? "PhoneBox.Generated"; ICollection models = CollectModels(context, container.Path, container.Document.Components.Schemas).ToArray(); if (models.Any() && outputFilter.HasFlag(SignalRHubGenerationOutputs.Model)) { @@ -78,7 +89,7 @@ private static void CollectSources(SourceProductionContext context, OpenApiDocum string className = $"{hubName}Hub"; if (outputFilter.HasFlag(SignalRHubGenerationOutputs.Interface)) - AddInterface(context, interfaceName, @namespace, hubGroup); + AddInterface(context, interfaceName, @namespace, contractNamespace, hubGroup); if (outputFilter.HasFlag(SignalRHubGenerationOutputs.Implementation)) AddImplementation(context, className, interfaceName, @namespace, contractNamespace); @@ -111,39 +122,35 @@ private static void RegisterPostInitializationOutput(IncrementalGeneratorPostIni } } - context.AddSource(fileName, content); + context.AddSource(fileName, $@"{GeneratedCodeHeader} + +{NormalizeEmbeddedSource(content)}"); } } - private static void AddImplementation(SourceProductionContext context, string className, string interfaceName, string? @namespace, string? contractNamespace) + private static void AddImplementation(SourceProductionContext context, string className, string interfaceName, string @namespace, string? contractNamespace) { - ICollection usings = new SortedSet(); - usings.Add("Microsoft.AspNetCore.SignalR"); - - if (contractNamespace != null) - usings.Add(contractNamespace); - - string usingsStr = String.Join(Environment.NewLine, usings.Select(x => $"using {x};")); string fileName = $"{className}.generated.cs"; - string content = $@"{usingsStr} + string content = $@"{GeneratedCodeHeader} namespace {@namespace} {{ - public partial class {className} : Hub<{interfaceName}> + public partial class {className} : global::Microsoft.AspNetCore.SignalR.Hub {{ }} }}"; context.AddSource(fileName, content); } - private static void AddInterface(SourceProductionContext context, string interfaceName, string? @namespace, IEnumerable methods) + private static void AddInterface(SourceProductionContext context, string interfaceName, string @namespace, string? contractNamespace, IEnumerable methods) { string fileName = $"{interfaceName}.generated.cs"; - string methodsStr = String.Join(Environment.NewLine, methods.Select(GenerateInterfaceMethod)); - string content = $@"using System.Threading.Tasks; + string methodsStr = String.Join(Environment.NewLine, methods.Select(x => GenerateInterfaceMethod(x, contractNamespace ?? @namespace))); + string content = $@"{GeneratedCodeHeader} namespace {@namespace} {{ +{GeneratedCodeAnnotationStr} public interface {interfaceName} {{ {methodsStr} @@ -152,13 +159,13 @@ public interface {interfaceName} context.AddSource(fileName, content); } - private static void AddModel(SourceProductionContext context, string? @namespace, OpenApiHubModel model) + private static void AddModel(SourceProductionContext context, string @namespace, OpenApiHubModel model) { string content = GenerateModel(@namespace, model); context.AddSource($"{model.Name}.generated.cs", content); } - private static string GenerateModel(string? @namespace, OpenApiHubModel model) + private static string GenerateModel(string @namespace, OpenApiHubModel model) { switch (model) { @@ -168,13 +175,16 @@ private static string GenerateModel(string? @namespace, OpenApiHubModel model) } } - private static string GenerateClass(string? @namespace, OpenApiHubClass @class) + private static string GenerateClass(string @namespace, OpenApiHubClass @class) { - string propertiesStr = String.Join(Environment.NewLine, @class.Properties.Select(x => $" public {x.TypeName} {x.PropertyName} {{ get; }}")); - string ctorParametersStr = String.Join(", ", @class.Properties.Select(x => $"{x.TypeName} {ToCamelCase(x.PropertyName)}")); + string propertiesStr = String.Join(Environment.NewLine, @class.Properties.Select(x => $" public {x.TypeName.GetGlobalTypeName(@namespace)} {x.PropertyName} {{ get; }}")); + string ctorParametersStr = String.Join(", ", @class.Properties.Select(x => $"{x.TypeName.GetGlobalTypeName(@namespace)} {ToCamelCase(x.PropertyName)}")); string ctorAssignmentsStr = String.Join(Environment.NewLine, @class.Properties.Select(x => $" this.{x.PropertyName} = {ToCamelCase(x.PropertyName)};")); - string content = $@"namespace {@namespace} + string content = $@"{GeneratedCodeHeader} + +namespace {@namespace} {{ +{DefaultAnnotationsStr} public sealed class {@class.Name} {{ {propertiesStr} @@ -188,11 +198,14 @@ public sealed class {@class.Name} return content; } - private static string GenerateEnum(string? @namespace, OpenApiHubEnum @enum) + private static string GenerateEnum(string @namespace, OpenApiHubEnum @enum) { string membersStr = String.Join($",{Environment.NewLine}", @enum.Members.Select(x => $" {x.Name} = {x.Value}")); - string content = $@"namespace {@namespace} + string content = $@"{GeneratedCodeHeader} + +namespace {@namespace} {{ +{GeneratedCodeAnnotationStr} public enum {@enum.Name} {{ {membersStr} @@ -201,23 +214,17 @@ public enum {@enum.Name} return content; } - private static void AddExtensions(SourceProductionContext context, string? @namespace, IEnumerable hubs) + private static void AddExtensions(SourceProductionContext context, string @namespace, IEnumerable hubs) { - ICollection usings = new SortedSet(); - usings.Add("Microsoft.AspNetCore.Routing"); - - if (@namespace != null) - usings.Add(@namespace); - - string usingsStr = String.Join(Environment.NewLine, usings.Select(x => $"using {x};")); - string methodsStr = String.Join($"{Environment.NewLine}{Environment.NewLine}", hubs.Select(x => @$" public static HubEndpointConventionBuilder MapHub(this IEndpointRouteBuilder endpoints) where THub : {x.Name} + string methodsStr = String.Join($"{Environment.NewLine}{Environment.NewLine}", hubs.Select(x => @$" public static global::Microsoft.AspNetCore.Builder.HubEndpointConventionBuilder MapHub(this global::Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints) where THub : global::{@namespace}.{x.Name} {{ return endpoints.MapHub(""{x.Path}""); }}")); - string content = $@"{usingsStr} + string content = $@"{GeneratedCodeHeader} namespace Microsoft.AspNetCore.Builder {{ +{DefaultAnnotationsStr} internal static class HubEndpointRouteBuilderExtensions {{ {methodsStr} @@ -226,10 +233,10 @@ internal static class HubEndpointRouteBuilderExtensions context.AddSource("HubEndpointRouteBuilderExtensions.generated.cs", content); } - private static string GenerateInterfaceMethod(OpenApiHubMethod method) + private static string GenerateInterfaceMethod(OpenApiHubMethod method, string @namespace) { - string parametersStr = String.Join(", ", method.Parameters.Select(x => $"{x.TypeName} {x.ParameterName}")); - string content = $" Task {method.MethodName}({parametersStr});"; + string parametersStr = String.Join(", ", method.Parameters.Select(x => $"{x.TypeName.GetGlobalTypeName(@namespace)} {x.ParameterName}")); + string content = $" global::System.Threading.Tasks.Task {method.MethodName}({parametersStr});"; return content; } @@ -314,30 +321,32 @@ private static IEnumerable CollectHubMethods(OpenApiDocumentCo } } - private static string GetCSharpTypeName(OpenApiSchema schema) + private static OpenApiTypeName GetCSharpTypeName(OpenApiSchema schema) { - string? typeName = GetOpenApiTypeName(schema); + string? typeName = GetOpenApiTypeName(schema, out bool isPrimitive); switch (typeName) { // TODO: Finish implementation - case null: - return "void"; - - case "boolean": - return "bool"; - - default: - return typeName; + case null: return new OpenApiTypeName("void", isPrimitive: true); + case "boolean": return new OpenApiTypeName("bool", isPrimitive: true); + default: return new OpenApiTypeName(typeName, isPrimitive); } } - private static string? GetOpenApiTypeName(OpenApiSchema schema) + private static string? GetOpenApiTypeName(OpenApiSchema schema, out bool isPrimitive) { if (schema.Reference != null) + { + isPrimitive = false; return schema.Reference.Id; + } if (schema.Type != null) + { + isPrimitive = true; return schema.Type; + } + isPrimitive = false; return null; } @@ -491,6 +500,12 @@ private static string NormalizeHubName(string hubName) return normalizedHubName; } + private static string ComputeDefaultAnnotationsStr() => String.Join(Environment.NewLine, Annotation.All.Select(ComputeAnnotationStr)); + + private static string ComputeGeneratedCodeAnnotationStr() => ComputeAnnotationStr(Annotation.GeneratedCode); + + private static string ComputeAnnotationStr(Annotation annotation) => $" [{annotation.Name}{annotation.Arguments}]"; + private static string ToCamelCase(string s) { if (String.IsNullOrEmpty(s) || !Char.IsUpper(s[0])) @@ -532,6 +547,41 @@ private static string ToCamelCase(string s) return new String(chars); } + private static string NormalizeEmbeddedSource(string content) + { + SyntaxTree syntaxTree = CSharpSyntaxTree.ParseText(content); + EmbeddedSourceNormalizationVisitor visitor = new EmbeddedSourceNormalizationVisitor(); + SyntaxNode normalizedNode = visitor.Visit(syntaxTree.GetRoot())!; + string normalizedContent = normalizedNode.ToFullString(); + return normalizedContent; + } + + private sealed class EmbeddedSourceNormalizationVisitor : CSharpSyntaxRewriter + { + public override SyntaxNode? VisitClassDeclaration(ClassDeclarationSyntax node) => node.WithAttributeLists(CreateAttributeLists(node, Annotation.All)); + + public override SyntaxNode? VisitEnumDeclaration(EnumDeclarationSyntax node) => node.WithAttributeLists(CreateAttributeLists(node, EnumerableExtensions.Create(Annotation.GeneratedCode))); + + private static SyntaxList CreateAttributeLists(MemberDeclarationSyntax node, IEnumerable annotations) + { + IEnumerable attributeLists = annotations.Select(x => SyntaxFactory.AttributeList(new SeparatedSyntaxList().Add(CreateAttribute(x.Name, x.Arguments))) + .WithLeadingTrivia(SyntaxFactory.Whitespace(new string(' ', 4))) + .WithTrailingTrivia(SyntaxFactory.EndOfLine(Environment.NewLine))) + .Concat(node.AttributeLists); + return new SyntaxList(attributeLists); + } + + private static AttributeSyntax CreateAttribute(string name, string? arguments) + { + AttributeArgumentListSyntax? argumentList = null; + if (arguments != null) + argumentList = SyntaxFactory.ParseAttributeArgumentList(arguments); + + AttributeSyntax attribute = SyntaxFactory.Attribute(SyntaxFactory.ParseName(name), argumentList); + return attribute; + } + } + private static class ErrorCode { private const string Prefix = "HUBGEN"; @@ -584,9 +634,9 @@ public OpenApiHubMethod(OpenApiHub hub, string methodName) private readonly struct OpenApiHubMethodParameter { public string ParameterName { get; } - public string TypeName { get; } + public OpenApiTypeName TypeName { get; } - public OpenApiHubMethodParameter(string parameterName, string typeName) + public OpenApiHubMethodParameter(string parameterName, OpenApiTypeName typeName) { this.ParameterName = parameterName; this.TypeName = typeName; @@ -616,9 +666,9 @@ public OpenApiHubClass(string name) : base(name) private readonly struct OpenApiHubClassProperty { public string PropertyName { get; } - public string TypeName { get; } + public OpenApiTypeName TypeName { get; } - public OpenApiHubClassProperty(string propertyName, string typeName) + public OpenApiHubClassProperty(string propertyName, OpenApiTypeName typeName) { this.PropertyName = propertyName; this.TypeName = typeName; @@ -646,5 +696,27 @@ public OpenApiHubEnumMember(string name, int value) this.Value = value; } } + + private readonly struct OpenApiTypeName + { + public string Name { get; } + public bool IsPrimitive { get; } + + public OpenApiTypeName(string name, bool isPrimitive) + { + this.Name = name; + this.IsPrimitive = isPrimitive; + } + + public string GetGlobalTypeName(string @namespace) + { + StringBuilder sb = new StringBuilder(this.Name); + if (!this.IsPrimitive) + sb.Insert(0, $"global::{@namespace}."); + + string globalTypeName = sb.ToString(); + return globalTypeName; + } + } } } \ No newline at end of file diff --git a/src/PhoneBox.Generators/Utilities/Annotation.cs b/src/PhoneBox.Generators/Utilities/Annotation.cs new file mode 100644 index 0000000..852da13 --- /dev/null +++ b/src/PhoneBox.Generators/Utilities/Annotation.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; + +namespace PhoneBox.Generators +{ + internal readonly struct Annotation + { + public string Name { get; } + public string? Arguments { get; } + + public static Annotation GeneratedCode = new Annotation("global::System.CodeDom.Compiler.GeneratedCode", $"(\"{(ThisAssembly.AssemblyTitle)}\", \"{(ThisAssembly.AssemblyFileVersion)}\")"); + public static Annotation DebuggerNonUserCode = new Annotation("global::System.Diagnostics.DebuggerNonUserCode"); + public static Annotation ExcludeFromCodeCoverage = new Annotation("global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage"); + public static IEnumerable All + { + get + { + yield return GeneratedCode; + yield return DebuggerNonUserCode; + yield return ExcludeFromCodeCoverage; + } + } + + private Annotation(string name, string? arguments = null) + { + this.Name = name; + this.Arguments = arguments; + } + } +} \ No newline at end of file diff --git a/tests/PhoneBox.Generators.Tests/GeneratorTest.cs b/tests/PhoneBox.Generators.Tests/GeneratorTest.cs index beca7e8..f8a2669 100644 --- a/tests/PhoneBox.Generators.Tests/GeneratorTest.cs +++ b/tests/PhoneBox.Generators.Tests/GeneratorTest.cs @@ -147,7 +147,7 @@ private Compilation RunGenerator(SignalRHubGenerationOutputs filter, string? met string actualCode = outputSyntaxTree.ToString(); this.AddResultFile(outputFile.Name, actualCode); Assert.AreEqual(expectedFiles[i - 1], outputFile.Name); - string expectedCode = this.GetEmbeddedResourceContent(outputFile.Name); + string expectedCode = this.GetEmbeddedResourceContent(outputFile.Name).Replace("%GENERATORVERSION%", ThisAssembly.AssemblyFileVersion); this.AssertEqual(expectedCode, actualCode, outputName: Path.GetFileNameWithoutExtension(outputFile.Name), extension: outputFile.Extension.TrimStart('.')); } } diff --git a/tests/PhoneBox.Generators.Tests/PhoneBox.Generators.Tests.csproj b/tests/PhoneBox.Generators.Tests/PhoneBox.Generators.Tests.csproj index 3ab0a49..fd447ec 100644 --- a/tests/PhoneBox.Generators.Tests/PhoneBox.Generators.Tests.csproj +++ b/tests/PhoneBox.Generators.Tests/PhoneBox.Generators.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0 diff --git a/tests/PhoneBox.Generators.Tests/PhoneBox.Generators.Tests.csproj.DotSettings b/tests/PhoneBox.Generators.Tests/PhoneBox.Generators.Tests.csproj.DotSettings index 89316e4..5973769 100644 --- a/tests/PhoneBox.Generators.Tests/PhoneBox.Generators.Tests.csproj.DotSettings +++ b/tests/PhoneBox.Generators.Tests/PhoneBox.Generators.Tests.csproj.DotSettings @@ -1,2 +1,3 @@  - Library \ No newline at end of file + Library + True \ No newline at end of file diff --git a/tests/PhoneBox.Generators.Tests/Resources/CallConnectedEvent.generated.cs b/tests/PhoneBox.Generators.Tests/Resources/CallConnectedEvent.generated.cs index 9895f52..c69746a 100644 --- a/tests/PhoneBox.Generators.Tests/Resources/CallConnectedEvent.generated.cs +++ b/tests/PhoneBox.Generators.Tests/Resources/CallConnectedEvent.generated.cs @@ -1,5 +1,17 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + namespace PhoneBox.Abstractions { + [global::System.CodeDom.Compiler.GeneratedCode("PhoneBox.Generators", "%GENERATORVERSION%")] + [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public sealed class CallConnectedEvent { public string PhoneNumber { get; } diff --git a/tests/PhoneBox.Generators.Tests/Resources/CallDisconnectedEvent.generated.cs b/tests/PhoneBox.Generators.Tests/Resources/CallDisconnectedEvent.generated.cs index ff9a8fc..1b33d10 100644 --- a/tests/PhoneBox.Generators.Tests/Resources/CallDisconnectedEvent.generated.cs +++ b/tests/PhoneBox.Generators.Tests/Resources/CallDisconnectedEvent.generated.cs @@ -1,5 +1,17 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + namespace PhoneBox.Abstractions { + [global::System.CodeDom.Compiler.GeneratedCode("PhoneBox.Generators", "%GENERATORVERSION%")] + [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] public sealed class CallDisconnectedEvent { public string PhoneNumber { get; } diff --git a/tests/PhoneBox.Generators.Tests/Resources/CallHangUpReason.generated.cs b/tests/PhoneBox.Generators.Tests/Resources/CallHangUpReason.generated.cs index 27dd0d9..9c41f07 100644 --- a/tests/PhoneBox.Generators.Tests/Resources/CallHangUpReason.generated.cs +++ b/tests/PhoneBox.Generators.Tests/Resources/CallHangUpReason.generated.cs @@ -1,5 +1,15 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + namespace PhoneBox.Abstractions { + [global::System.CodeDom.Compiler.GeneratedCode("PhoneBox.Generators", "%GENERATORVERSION%")] public enum CallHangUpReason { None = 0, diff --git a/tests/PhoneBox.Generators.Tests/Resources/CallState.generated.cs b/tests/PhoneBox.Generators.Tests/Resources/CallState.generated.cs index f1414de..5b8862b 100644 --- a/tests/PhoneBox.Generators.Tests/Resources/CallState.generated.cs +++ b/tests/PhoneBox.Generators.Tests/Resources/CallState.generated.cs @@ -1,5 +1,15 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + namespace PhoneBox.Abstractions { + [global::System.CodeDom.Compiler.GeneratedCode("PhoneBox.Generators", "%GENERATORVERSION%")] public enum CallState { None = 0, diff --git a/tests/PhoneBox.Generators.Tests/Resources/HubEndpointRouteBuilderExtensions.generated.cs b/tests/PhoneBox.Generators.Tests/Resources/HubEndpointRouteBuilderExtensions.generated.cs index aa80238..cd718e0 100644 --- a/tests/PhoneBox.Generators.Tests/Resources/HubEndpointRouteBuilderExtensions.generated.cs +++ b/tests/PhoneBox.Generators.Tests/Resources/HubEndpointRouteBuilderExtensions.generated.cs @@ -1,11 +1,20 @@ -using Microsoft.AspNetCore.Routing; -using PhoneBox.Generators.Tests; +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ namespace Microsoft.AspNetCore.Builder { + [global::System.CodeDom.Compiler.GeneratedCode("PhoneBox.Generators", "%GENERATORVERSION%")] + [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static class HubEndpointRouteBuilderExtensions { - public static HubEndpointConventionBuilder MapHub(this IEndpointRouteBuilder endpoints) where THub : TelephonyHub + public static global::Microsoft.AspNetCore.Builder.HubEndpointConventionBuilder MapHub(this global::Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints) where THub : global::PhoneBox.Generators.Tests.TelephonyHub { return endpoints.MapHub("/TelephonyHub"); } diff --git a/tests/PhoneBox.Generators.Tests/Resources/ITelephonyHub.generated.cs b/tests/PhoneBox.Generators.Tests/Resources/ITelephonyHub.generated.cs index 98d8eb4..2d5ab11 100644 --- a/tests/PhoneBox.Generators.Tests/Resources/ITelephonyHub.generated.cs +++ b/tests/PhoneBox.Generators.Tests/Resources/ITelephonyHub.generated.cs @@ -1,10 +1,18 @@ -using System.Threading.Tasks; +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ namespace PhoneBox.Abstractions { + [global::System.CodeDom.Compiler.GeneratedCode("PhoneBox.Generators", "%GENERATORVERSION%")] public interface ITelephonyHub { - Task ReceiveCallConnected(CallConnectedEvent content); - Task ReceiveCallDisconnected(CallDisconnectedEvent content); + global::System.Threading.Tasks.Task ReceiveCallConnected(global::PhoneBox.Abstractions.CallConnectedEvent content); + global::System.Threading.Tasks.Task ReceiveCallDisconnected(global::PhoneBox.Abstractions.CallDisconnectedEvent content); } } \ No newline at end of file diff --git a/tests/PhoneBox.Generators.Tests/Resources/SignalRHubGenerationAttribute.generated.cs b/tests/PhoneBox.Generators.Tests/Resources/SignalRHubGenerationAttribute.generated.cs index 35e23da..057bba0 100644 --- a/tests/PhoneBox.Generators.Tests/Resources/SignalRHubGenerationAttribute.generated.cs +++ b/tests/PhoneBox.Generators.Tests/Resources/SignalRHubGenerationAttribute.generated.cs @@ -1,13 +1,23 @@ -using System; +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ namespace PhoneBox.Generators { - [AttributeUsage(AttributeTargets.Assembly)] - internal sealed class SignalRHubGenerationAttribute : Attribute + [global::System.CodeDom.Compiler.GeneratedCode("PhoneBox.Generators", "%GENERATORVERSION%")] + [global::System.Diagnostics.DebuggerNonUserCode] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.AttributeUsage(global::System.AttributeTargets.Assembly)] + internal sealed class SignalRHubGenerationAttribute : global::System.Attribute { - public SignalRHubGenerationOutputs OutputFilter { get; } + public global::PhoneBox.Generators.SignalRHubGenerationOutputs OutputFilter { get; } - public SignalRHubGenerationAttribute(SignalRHubGenerationOutputs outputFilter = SignalRHubGenerationOutputs.All) + public SignalRHubGenerationAttribute(global::PhoneBox.Generators.SignalRHubGenerationOutputs outputFilter = global::PhoneBox.Generators.SignalRHubGenerationOutputs.All) { OutputFilter = outputFilter; } diff --git a/tests/PhoneBox.Generators.Tests/Resources/SignalRHubGenerationOutputs.generated.cs b/tests/PhoneBox.Generators.Tests/Resources/SignalRHubGenerationOutputs.generated.cs index 04a96e8..ee24af5 100644 --- a/tests/PhoneBox.Generators.Tests/Resources/SignalRHubGenerationOutputs.generated.cs +++ b/tests/PhoneBox.Generators.Tests/Resources/SignalRHubGenerationOutputs.generated.cs @@ -1,8 +1,16 @@ -using System; +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ namespace PhoneBox.Generators { - [Flags] + [global::System.CodeDom.Compiler.GeneratedCode("PhoneBox.Generators", "%GENERATORVERSION%")] + [global::System.Flags] internal enum SignalRHubGenerationOutputs { None = 0, diff --git a/tests/PhoneBox.Generators.Tests/Resources/TelephonyHub.generated.cs b/tests/PhoneBox.Generators.Tests/Resources/TelephonyHub.generated.cs index c034099..c6415bb 100644 --- a/tests/PhoneBox.Generators.Tests/Resources/TelephonyHub.generated.cs +++ b/tests/PhoneBox.Generators.Tests/Resources/TelephonyHub.generated.cs @@ -1,9 +1,15 @@ -using Microsoft.AspNetCore.SignalR; -using PhoneBox.Abstractions; +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ namespace PhoneBox.Generators.Tests { - public partial class TelephonyHub : Hub + public partial class TelephonyHub : global::Microsoft.AspNetCore.SignalR.Hub { } } \ No newline at end of file