Esempio n. 1
0
        public async Task XmlDoc_CheckAllAssemblies_HaveExamples()
        {
            var helper     = new Opinion.Opinion();
            var allClasses = await helper.GetProjectClasses(".");

            foreach (var projectClass in allClasses)
            {
                var codeText = new StreamReader(projectClass).ReadToEnd();
                var code     = MetadataReference.CreateFromFile(typeof(object).Assembly.Location);

                // Parse the C# code...
                CSharpParseOptions parseOptions = new CSharpParseOptions()
                                                  .WithKind(SourceCodeKind.Regular)             // ...as representing a complete .cs file
                                                  .WithLanguageVersion(LanguageVersion.Latest); // ...enabling the latest language features

                // Compile the C# code...
                CSharpCompilationOptions compileOptions =
                    new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary) // ...to a dll
                    .WithOptimizationLevel(OptimizationLevel.Release)                 // ...in Release configuration
                    .WithAllowUnsafe(enabled: true);                                  // ...enabling unsafe code

                // Invoke the compiler...
                CSharpCompilation compilation =
                    CSharpCompilation.Create("TestInMemoryAssembly")                                    // ..with some fake dll name
                    .WithOptions(compileOptions)
                    .AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location)); // ...referencing the same mscorlib we're running on

                // Parse and compile the C# code into a *.dll and *.xml file in-memory
                var tree           = CSharpSyntaxTree.ParseText(codeText, parseOptions);
                var newCompilation = compilation.AddSyntaxTrees(tree);
            }
        }
Esempio n. 2
0
        public void Library_ParseXmlDoc_ReturnTreeText()
        {
            var obj = new Opinion.Opinion();

            Assert.NotNull(obj);
        }