Skip to content

Commit aa02505

Browse files
committed
修改接口名相同时的问题
1 parent 442066b commit aa02505

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

WebApiClientCore.Analyzers/SourceGenerator/HttpApiProxyClass.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ sealed class HttpApiProxyClass : IEquatable<HttpApiProxyClass>
3131
/// <summary>
3232
/// 文件名
3333
/// </summary>
34-
public string FileName => $"{nameof(HttpApiProxyClass)}.{this.httpApi.ToDisplayString()}.g.cs";
34+
public string FileName { get; }
3535

3636
/// <summary>
3737
/// 类型名
3838
/// </summary>
39-
public string ClassName => this.httpApi.Name;
39+
public string ClassName { get; }
4040

4141
/// <summary>
4242
/// HttpApi代理类
@@ -46,6 +46,10 @@ public HttpApiProxyClass(INamedTypeSymbol httpApi)
4646
{
4747
this.httpApi = httpApi;
4848
this.httpApiFullName = GetFullName(httpApi);
49+
50+
var httpApiName = httpApi.ToDisplayString();
51+
this.FileName = $"{nameof(HttpApiProxyClass)}.{httpApiName}.g.cs";
52+
this.ClassName = httpApiName.Replace(".", "_");
4953
}
5054

5155
/// <summary>
@@ -63,7 +67,7 @@ private static string GetFullName(ISymbol symbol)
6367
/// </summary>
6468
/// <returns></returns>
6569
public SourceText ToSourceText()
66-
{
70+
{
6771
var code = this.ToString();
6872
return SourceText.From(code, Encoding.UTF8);
6973
}

0 commit comments

Comments
 (0)