gpt4 book ai didi

c# - ISymbol.DeclaringSyntaxReferences 和 ISymbol.Locations 之间的区别

转载 作者:行者123 更新时间:2023-11-30 15:20:58 26 4
gpt4 key购买 nike

DeclaringSyntaxReferences 之间有什么区别?属性(property)和Locations ISyntax 中的属性(property)界面?

最佳答案

答案的线索在 <remarks> 中评论区:

The syntax node(s) that declared the symbol. If the symbol was declared in metadata or was implicitly declared, returns an empty read-only array.

这意味着 Locations还返回元数据引用声明和隐式声明的位置。您可以在 LocationsTests.cs 中看到这方面的证据文件:

var c = s.GetTypeMembers("C", 0).Single() as NamedTypeSymbol;
var obj = c.BaseType;
Assert.Equal("MetadataFile(CommonLanguageRuntimeLibrary)", obj.Locations[0].ToString());

哪里cclass C在:

namespace N.S{class C{int F; void M(int P}{}}

所以 objSystem.Object .这是有道理的,因为您没有任何实际的源代码,因此在编译中没有定义 System.Object语法 .

关于c# - ISymbol.DeclaringSyntaxReferences 和 ISymbol.Locations 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38775807/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com