Skip to content

Commit

Permalink
Merge pull request #1056 from reactiveui/cleanup
Browse files Browse the repository at this point in the history
Remove "AutoGenerated" as it's redundant
  • Loading branch information
clairernovotny authored Feb 4, 2021
2 parents 847e514 + c7919d6 commit f3432c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions InterfaceStubGenerator.Core/InterfaceStubGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
{{
Expand All @@ -233,7 +233,7 @@ partial class AutoGenerated{ns}{classDeclaration}
readonly global::Refit.IRequestBuilder requestBuilder;
/// <inheritdoc />
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;
Expand Down
17 changes: 8 additions & 9 deletions Refit.Tests/InterfaceStubGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Microsoft.CodeAnalysis.Text;

using Refit.Generator;
using Refit.Implementation;

using Xunit;

Expand Down Expand Up @@ -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
{
Expand All @@ -167,7 +166,7 @@ partial class AutoGeneratedRefitTestsIGitHubApi
readonly global::Refit.IRequestBuilder requestBuilder;
/// <inheritdoc />
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;
Expand Down Expand Up @@ -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
{
Expand All @@ -307,7 +306,7 @@ partial class AutoGeneratedRefitTestsIGitHubApiDisposable
readonly global::Refit.IRequestBuilder requestBuilder;
/// <inheritdoc />
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;
Expand Down Expand Up @@ -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
{
Expand All @@ -357,7 +356,7 @@ partial class AutoGeneratedRefitTestsTestNestedINestedGitHubApi
readonly global::Refit.IRequestBuilder requestBuilder;
/// <inheritdoc />
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;
Expand Down Expand Up @@ -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
{
Expand All @@ -523,7 +522,7 @@ partial class AutoGeneratedIServiceWithoutNamespace
readonly global::Refit.IRequestBuilder requestBuilder;
/// <inheritdoc />
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;
Expand Down
7 changes: 3 additions & 4 deletions Refit/UniqueName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public static string ForType<T>()

public static string ForType(Type refitInterfaceType)
{

var interfaceTypeName = refitInterfaceType.FullName!;

// remove namespace/nested, up to anything before a `
Expand All @@ -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)
Expand All @@ -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}";

Expand Down

0 comments on commit f3432c4

Please sign in to comment.