NRefactory是否了解来自C#的WinRT语言投影?如果没有,那么将此功能添加到NRefactory的最简单方法是什么?
以下单元测试似乎表明它目前不支持它。解析Windows.Globalization.ApplicationLanguages.Languages[0]
应解析为System.String,但这会失败。我的理论是解析器希望找到一个索引器,但没有一个因为它实际上是IVector.GetAt(...)
的项目。
要重现此问题,请克隆NRefactory,然后添加文件ICSharpCode.NRefactory.Tests\CSharp\Resolver\WinrtTests.cs
:
using ICSharpCode.NRefactory.TypeSystem;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Resolver
{
public class WinrtTests : ResolverTestBase
{
public override void SetUp()
{
var loader = new CecilLoader();
project = new CSharpProjectContent().AddAssemblyReferences(new [] {
CecilLoaderTests.Mscorlib,
loader.LoadAssemblyFile(@"C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\Windows.winmd")
});
compilation = project.CreateCompilation();
}
[Test]
public void FixedStatement()
{
const string program =
@"class TestClass
{
static void Main()
{
var i = $Windows.Globalization.ApplicationLanguages.Languages[0]$;
}
}";
var rr = Resolve(program);
Assert.AreEqual("System.String", rr.Type.FullName);
}
}
}