Skip to content

fix generatetype assembly ref issue#13

Open
LumiaSnow wants to merge 1 commit intojiangjinnan:masterfrom
LumiaSnow:fix-generictype-assembly-ref-issue
Open

fix generatetype assembly ref issue#13
LumiaSnow wants to merge 1 commit intojiangjinnan:masterfrom
LumiaSnow:fix-generictype-assembly-ref-issue

Conversation

@LumiaSnow
Copy link

@LumiaSnow LumiaSnow commented Jul 3, 2023

When I regist interception to the method which have return or parameter of generatetype, for example:

public virtual async Task< Class2 > Invoke(); // Class2 is from another assembly.

I got the error:

Dora.Interception.InterceptionException:“It fails to generate proxy class.
(69,60): error CS0246: 未能找到类型或命名空间名“ClassLibrary1”(是否缺少 using 指令或程序集引用?)
(69,82): error CS0012: 类型“Class2”在未引用的程序集中定义。必须添加对程序集“ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”的引用。
(16,50): error CS0246: 未能找到类型或命名空间名“ClassLibrary1”(是否缺少 using 指令或程序集引用?)
(59,141): error CS0246: 未能找到类型或命名空间名“ClassLibrary1”(是否缺少 using 指令或程序集引用?)
(60,189): error CS0246: 未能找到类型或命名空间名“ClassLibrary1”(是否缺少 using 指令或程序集引用?)
(82,31): error CS0012: 类型“Class2”在未引用的程序集中定义。必须添加对程序集“ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”的引用。
(83,36): error CS0029: 无法将类型“System.Threading.Tasks.Task<ClassLibrary1.Class2>”隐式转换为“System.Threading.Tasks.Task<ClassLibrary1.Class2>””

I found the reason:
The method CodeGenerationContext.References.Add(Assembly assembly) can not add the assemly for the parameter of generatetype.

Fix:
Add a method AddReference, if the type is generatetype, add the assembly recursively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments