From c7919d6e3aace8a16441ef24237dedbfcf8dbd74 Mon Sep 17 00:00:00 2001 From: Claire Novotny Date: Thu, 4 Feb 2021 12:21:29 -0500 Subject: [PATCH] Remove "AutoGenerated" as it's redundant now that code is generated underneath a Generated class --- .../InterfaceStubGenerator.cs | 4 ++-- Refit.Tests/InterfaceStubGenerator.cs | 17 ++++++++--------- Refit/UniqueName.cs | 7 +++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs index 98201884a..e8e69152c 100644 --- a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs +++ b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs @@ -224,7 +224,7 @@ partial class Generated [{preserveAttributeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}] [global::System.Reflection.Obfuscation(Exclude=true)] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - partial class AutoGenerated{ns}{classDeclaration} + partial class {ns}{classDeclaration} : {interfaceSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}{GenerateConstraints(interfaceSymbol.TypeParameters, false)} {{ @@ -233,7 +233,7 @@ partial class AutoGenerated{ns}{classDeclaration} readonly global::Refit.IRequestBuilder requestBuilder; /// - public AutoGenerated{ns}{classSuffix}(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder) + public {ns}{classSuffix}(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder) {{ Client = client; this.requestBuilder = requestBuilder; diff --git a/Refit.Tests/InterfaceStubGenerator.cs b/Refit.Tests/InterfaceStubGenerator.cs index a431406ba..f9e78734b 100644 --- a/Refit.Tests/InterfaceStubGenerator.cs +++ b/Refit.Tests/InterfaceStubGenerator.cs @@ -13,7 +13,6 @@ using Microsoft.CodeAnalysis.Text; using Refit.Generator; -using Refit.Implementation; using Xunit; @@ -158,7 +157,7 @@ partial class Generated [global::RefitInternalGenerated.PreserveAttribute] [global::System.Reflection.Obfuscation(Exclude=true)] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - partial class AutoGeneratedRefitTestsIGitHubApi + partial class RefitTestsIGitHubApi : global::Refit.Tests.IGitHubApi { @@ -167,7 +166,7 @@ partial class AutoGeneratedRefitTestsIGitHubApi readonly global::Refit.IRequestBuilder requestBuilder; /// - public AutoGeneratedRefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder) + public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder) { Client = client; this.requestBuilder = requestBuilder; @@ -298,7 +297,7 @@ partial class Generated [global::RefitInternalGenerated.PreserveAttribute] [global::System.Reflection.Obfuscation(Exclude=true)] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - partial class AutoGeneratedRefitTestsIGitHubApiDisposable + partial class RefitTestsIGitHubApiDisposable : global::Refit.Tests.IGitHubApiDisposable { @@ -307,7 +306,7 @@ partial class AutoGeneratedRefitTestsIGitHubApiDisposable readonly global::Refit.IRequestBuilder requestBuilder; /// - public AutoGeneratedRefitTestsIGitHubApiDisposable(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder) + public RefitTestsIGitHubApiDisposable(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder) { Client = client; this.requestBuilder = requestBuilder; @@ -348,7 +347,7 @@ partial class Generated [global::RefitInternalGenerated.PreserveAttribute] [global::System.Reflection.Obfuscation(Exclude=true)] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - partial class AutoGeneratedRefitTestsTestNestedINestedGitHubApi + partial class RefitTestsTestNestedINestedGitHubApi : global::Refit.Tests.TestNested.INestedGitHubApi { @@ -357,7 +356,7 @@ partial class AutoGeneratedRefitTestsTestNestedINestedGitHubApi readonly global::Refit.IRequestBuilder requestBuilder; /// - public AutoGeneratedRefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder) + public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder) { Client = client; this.requestBuilder = requestBuilder; @@ -514,7 +513,7 @@ partial class Generated [global::RefitInternalGenerated.PreserveAttribute] [global::System.Reflection.Obfuscation(Exclude=true)] [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] - partial class AutoGeneratedIServiceWithoutNamespace + partial class IServiceWithoutNamespace : global::IServiceWithoutNamespace { @@ -523,7 +522,7 @@ partial class AutoGeneratedIServiceWithoutNamespace readonly global::Refit.IRequestBuilder requestBuilder; /// - public AutoGeneratedIServiceWithoutNamespace(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder) + public IServiceWithoutNamespace(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder) { Client = client; this.requestBuilder = requestBuilder; diff --git a/Refit/UniqueName.cs b/Refit/UniqueName.cs index caeb6e9a0..230b22cc0 100644 --- a/Refit/UniqueName.cs +++ b/Refit/UniqueName.cs @@ -11,7 +11,6 @@ public static string ForType() public static string ForType(Type refitInterfaceType) { - var interfaceTypeName = refitInterfaceType.FullName!; // remove namespace/nested, up to anything before a ` @@ -27,7 +26,6 @@ public static string ForType(Type refitInterfaceType) // Now we have the interface name like IFooBar`1[[Some Generic Args]] // Or Nested+IFrob - var genericArgs = string.Empty; // if there's any generics, split that if(refitInterfaceType.IsGenericType) @@ -39,13 +37,14 @@ public static string ForType(Type refitInterfaceType) // Remove any + from the type name portion interfaceTypeName = interfaceTypeName.Replace("+", ""); + // Get the namespace and remove the dots var ns = refitInterfaceType.Namespace?.Replace(".", ""); // Refit types will be generated as private classes within a Generated type in namespace // Refit.Implementation - // E.g., Refit.Implementation.Generated.AutoGeneratedInterfaceNamespaceContaingTYpeInterfaceType + // E.g., Refit.Implementation.Generated.NamespaceContaingTpeInterfaceType - var refitTypeName = $"Refit.Implementation.Generated+AutoGenerated{ns}{interfaceTypeName}{genericArgs}"; + var refitTypeName = $"Refit.Implementation.Generated+{ns}{interfaceTypeName}{genericArgs}"; var assmQualified = $"{refitTypeName}, {refitInterfaceType.Assembly.FullName}";