inversionhourglass / Rougamo

Compile-time AOP component. Works with any method, whether it is async or sync, instance or static. Uses an aspectj-like pattern to match methods.
MIT License
393 stars 47 forks source link

使用 Rougamo 2.2.0 自定义AsyncMethodBuilder。 #60

Closed abramped closed 7 months ago

abramped commented 7 months ago

方法返回自定义AsyncMethodBuilder,AOP异常,Rougamo的官方版本

MSBUILD : error : Type: 10>MSBUILD : error : System.Exception 10>MSBUILD : error : StackTrace: 10>MSBUILD : error : 在 InnerWeaver.ExecuteWeavers() 位置 C:\projects\fody\FodyIsolated\InnerWeaver.cs:行号 219 10>MSBUILD : error : 在 InnerWeaver.Execute() 位置 C:\projects\fody\FodyIsolated\InnerWeaver.cs:行号 111 10>MSBUILD : error : Source: 10>MSBUILD : error : FodyIsolated 10>MSBUILD : error : TargetSite: 10>MSBUILD : error : Void ExecuteWeavers() 10>MSBUILD : error : Unable to cast object of type 'Mono.Cecil.TypeReference' to type 'Mono.Cecil.GenericInstanceType'. 10>MSBUILD : error : Type: 10>MSBUILD : error : System.InvalidCastException 10>MSBUILD : error : StackTrace: 10>MSBUILD : error : 在 Rougamo.Fody.ModuleWeaver.AsyncResolveReturnBoxTypeRef(TypeReference returnTypeRef, FieldReference builderField) 10>MSBUILD : error : 在 Rougamo.Fody.ModuleWeaver.AsyncTaskMethodWeave(RouMethod rouMethod) 10>MSBUILD : error : 在 Rougamo.Fody.ModuleWeaver.WeaveMos() 10>MSBUILD : error : 在 InnerWeaver.ExecuteWeavers() 位置 C:\projects\fody\FodyIsolated\InnerWeaver.cs:行号 196 10>MSBUILD : error : Source: 10>MSBUILD : error : Rougamo.Fody 10>MSBUILD : error : TargetSite: 10>MSBUILD : error : Rougamo.Fody.Enhances.BoxTypeReference AsyncResolveReturnBoxTypeRef(Mono.Cecil.TypeReference, Mono.Cecil.FieldReference) 10>MSBUILD : error :

inversionhourglass commented 7 months ago

未提供有效信息

abramped commented 7 months ago

未提供有效信息 [AsyncMethodBuilder(typeof(AsyncAVoidMethodBuilder))] public readonly struct AVoid { [DebuggerHidden] public static AVoid Completed => default(AVoid);

    [DebuggerHidden]
    public bool IsCompleted => true;
}

[CusMoAttribute]] class TestA { public async AVoid Test() { return AVoid.Completed; } } 编译AOP报错如上。

inversionhourglass commented 7 months ago

目前不支持自定义AsyncMethodBuilder,Rougamo固定了异步的实现类型

https://github.com/inversionhourglass/Rougamo/blob/1d7771c7ae44388d4375406ffcf1755b439c8b89/src/Rougamo.Fody/Constants.cs#L33-L37

受限于当前版本代码织入方式,想要在当前版本支持自定义AsyncMethodBuilder会比较复杂。3.0版本将会修改代码织入方式,之后或许可以尝试支持自定义AsyncMethodBuilder

abramped commented 7 months ago

感谢回复!

inversionhourglass commented 5 months ago

3.0版本已支持自定义AsyncMethodBuilder