提交 131dcc20 编写于 作者: J johnche

获取builder如果出现异常,只打印,不中断注入,fix https://github.com/Tencent/InjectFix/issues/332

上级 c1e1c688
......@@ -2239,35 +2239,42 @@ namespace IFix
{
foreach(var nestedType in typeDefinition.NestedTypes)
{
var isStateMachine =
nestedType.Interfaces.Any(e => e.InterfaceType.Name == "IAsyncStateMachine");
if(!isStateMachine)
continue;
var builder = nestedType.Fields.First(e => e.Name.EndsWith("builder"));
var builderType = builder.FieldType;
try
{
var isStateMachine =
nestedType.Interfaces.Any(e => e.InterfaceType.Name == "IAsyncStateMachine");
if(builderType.ContainsGenericParameter)
continue;
if(!isStateMachine)
continue;
if(!builderType.IsValueType)
continue;
var builder = nestedType.Fields.First(e => e.Name.EndsWith("builder"));
var builderType = builder.FieldType;
if(builderType.IsGenericInstance)
{
if(genericBuilders.Any(e => ((GenericInstanceType) e).GenericArguments[0]
== ((GenericInstanceType) builderType).GenericArguments[0]))
if(builderType.ContainsGenericParameter)
continue;
genericBuilders.Add(builderType);
}
else
{
if(builders.Contains(builderType))
if(!builderType.IsValueType)
continue;
builders.Add(builderType);
if(builderType.IsGenericInstance)
{
if(genericBuilders.Any(e => ((GenericInstanceType) e).GenericArguments[0]
== ((GenericInstanceType) builderType).GenericArguments[0]))
continue;
genericBuilders.Add(builderType);
}
else
{
if(builders.Contains(builderType))
continue;
builders.Add(builderType);
}
}
catch (Exception e)
{
Console.WriteLine("Warning: get builder in " + typeDefinition + " throw: " + e);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册