2016-09-14 4 views
0

type Instance() => this;インスタンスの種類がExplicitのIInstanceReferenceExpression操作を取得していますが、その種類はThisと予想されます。何かが見つからないのですか?これはRoslynのバグですか? githubの上Roslyn明示的なIInstanceReferenceExpressionこの代わりに

using Microsoft.CodeAnalysis; 
using Microsoft.CodeAnalysis.CSharp; 
using Microsoft.CodeAnalysis.CSharp.Syntax; 
using Microsoft.CodeAnalysis.Semantics; 
using System; 
using System.Linq; 

internal static class so39495857 
{ 
    private static void Main() 
    { 
     var tree = CSharpSyntaxTree.ParseText(@" 
class c 
{ 
    c Instance() => this; 
    static void Main() {} 
} 
"); 
     var mscorlib = MetadataReference.CreateFromFile(typeof(object).Assembly.Location); 
     var compilation = CSharpCompilation.Create(null, new[] { tree }, new[] { mscorlib }); 
     var model = compilation.GetSemanticModel(tree); 
     var node = tree.GetRoot().DescendantNodes().OfType<ArrowExpressionClauseSyntax>().First(); 
     var operation = model.GetOperation(node); 
     var block = (IBlockStatement)operation; 
     var @return = (IReturnStatement)block.Statements.First(); 
     var @this = (IInstanceReferenceExpression)@return.ReturnedValue; 
     Console.WriteLine(@this.InstanceReferenceKind); 
    } 
} 

プロジェクト - https://github.com/isanych/so-39495857

答えて

1

Explicit手段です。

ThisClass is only for VB's MyClass keyword

+0

ありがとうございます、私はResharperを使用しており、デフォルトでデコンパイルされたコードを見ていますが、そこにコメントはありませんので、私はそれを見逃しました。 – ISanych

関連する問題