作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
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());
哪里c
是class C
在:
namespace N.S{class C{int F; void M(int P}{}}
所以 obj
是System.Object
.这是有道理的,因为您没有任何实际的源代码,因此在编译中没有定义 System.Object
的语法 .
关于c# - ISymbol.DeclaringSyntaxReferences 和 ISymbol.Locations 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38775807/
DeclaringSyntaxReferences 之间有什么区别?属性(property)和Locations ISyntax 中的属性(property)界面? 最佳答案 答案的线索在 中评论区
我是一名优秀的程序员,十分优秀!