fix generatetype assembly ref issue#13
Open
LumiaSnow wants to merge 1 commit intojiangjinnan:masterfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.