示例#1
0
        protected void AssertEmptyDiagnostics(TestLangOneCompilation compilation)
        {
            var diagnostics = compilation.GetDiagnostics();

            if (diagnostics.Length > 0)
            {
                Assert.Null(diagnostics[0]);
            }
        }
示例#2
0
        protected TestLangOneCompilation Compile(string testId, string fileId, bool assertEmptyDiagnostics = true)
        {
            TestLangOneDescriptor.Initialize();
            string text    = File.ReadAllText($@"..\..\..\InputFiles\Test{testId}-File{fileId}.txt");
            var    st      = TestLangOneSyntaxTree.ParseText(text);
            var    options = new TestLangOneCompilationOptions(TestLangOneLanguage.Instance, Microsoft.CodeAnalysis.OutputKind.DynamicallyLinkedLibrary, topLevelBinderFlags: (BinderFlags)BinderFlags.IgnoreAccessibility /*, concurrentBuild: false*/);
            var    comp    = TestLangOneCompilation.Create("Test").WithOptions(options).AddSyntaxTrees(st);

            comp.ForceComplete();
            if (assertEmptyDiagnostics)
            {
                AssertEmptyDiagnostics(comp);
            }
            return(comp);
        }