8000 Remove "AutoGenerated" as it's redundant by clairernovotny · Pull Request #1056 · reactiveui/refit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove "AutoGenerated" as it's redundant #1056

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

Merged
merged 1 commit into from
Feb 4, 2021
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
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