Does NRefactory understand WinRT language projection from C#? If not then what would be the easiest way to add this functionality to NRefactory?
The following unit test seems to indicate that it does not currently support it. Resolving Windows.Globalization.ApplicationLanguages.Languages[0]
should resolve to System.String, but this fails. My theory is that the resolver expects to find an indexer, but there isn't one because it is actually a project of IVector.GetAt(...)
.
To reproduce this issue, clone NRefactory, and add the file 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);
}
}
}