Skip to content

Commit 2e1a8c5

Browse files
committed
移除接口排序操作
1 parent 2afe6e5 commit 2e1a8c5

File tree

1 file changed

+1
-49
lines changed

1 file changed

+1
-49
lines changed

WebApiClientCore/BuildinExtensions/TypeExtensions.cs

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Linq;
44
using System.Linq.Expressions;
55
using System.Reflection;
6-
using System.Text;
76
using System.Threading.Tasks;
87
using WebApiClientCore.Exceptions;
98

@@ -89,10 +88,9 @@ public static MethodInfo[] GetAllApiMethods(this Type interfaceType)
8988
throw new ArgumentException(Resx.required_InterfaceType.Format(interfaceType.Name));
9089
}
9190

92-
var apiMethods = new[] { interfaceType }.Concat(interfaceType.GetInterfaces())
91+
var apiMethods = interfaceType.GetInterfaces().Append(interfaceType)
9392
.SelectMany(item => item.GetMethods())
9493
.Select(item => item.EnsureApiMethod())
95-
.OrderBy(item => item.GetFullName())
9694
.ToArray();
9795

9896
return apiMethods;
@@ -153,51 +151,5 @@ private static bool IsTaskReturn(this MethodInfo method)
153151
var taskType = method.ReturnType.GetGenericTypeDefinition();
154152
return taskType == typeof(ITask<>);
155153
}
156-
157-
/// <summary>
158-
/// 返回方法的完整名称
159-
/// </summary>
160-
/// <param name="method">方法</param>
161-
/// <returns></returns>
162-
private static string GetFullName(this MethodInfo method)
163-
{
164-
var builder = new StringBuilder();
165-
foreach (var p in method.GetParameters())
166-
{
167-
if (builder.Length > 0)
168-
{
169-
builder.Append(",");
170-
}
171-
builder.Append(p.ParameterType.GetName());
172-
}
173-
174-
var insert = $"{method.ReturnType.GetName()} {method.Name}(";
175-
return builder.Insert(0, insert).Append(")").ToString();
176-
}
177-
178-
/// <summary>
179-
/// 返回类型不含namespace的名称
180-
/// </summary>
181-
/// <param name="type">类型</param>
182-
/// <returns></returns>
183-
private static string GetName(this Type type)
184-
{
185-
if (type.IsGenericType == false)
186-
{
187-
return type.Name;
188-
}
189-
190-
var builder = new StringBuilder();
191-
foreach (var argType in type.GetGenericArguments())
192-
{
193-
if (builder.Length > 0)
194-
{
195-
builder.Append(",");
196-
}
197-
builder.Append(argType.GetName());
198-
}
199-
200-
return builder.Insert(0, $"{type.Name}<").Append(">").ToString();
201-
}
202154
}
203155
}

0 commit comments

Comments
 (0)