예제 #1
0
        public void DifferingMvids()
        {
            var directory = Temp.CreateDirectory();

            // Load Beta.dll from the future Alpha.dll path to prime the assembly loader
            var alphaDll = directory
                           .CreateFile("Alpha.dll")
                           .WriteAllBytes(TestResources.AssemblyLoadTests.Beta);

            var assemblyLoader = new InMemoryAssemblyLoader();
            var betaAssembly   = assemblyLoader.LoadFromPath(alphaDll.Path);

            alphaDll.WriteAllBytes(TestResources.AssemblyLoadTests.Alpha);
            var gammaDll = directory
                           .CreateFile("Gamma.dll")
                           .WriteAllBytes(TestResources.AssemblyLoadTests.Gamma);
            var deltaDll = directory
                           .CreateFile("Delta.dll")
                           .WriteAllBytes(TestResources.AssemblyLoadTests.Delta);

            var analyzerReferences = ImmutableArray.Create(
                new CommandLineAnalyzerReference("Alpha.dll"),
                new CommandLineAnalyzerReference("Gamma.dll"),
                new CommandLineAnalyzerReference("Delta.dll")
                );

            var result = AnalyzerConsistencyChecker.Check(
                directory.Path,
                analyzerReferences,
                assemblyLoader,
                Logger
                );

            Assert.False(result);
        }
예제 #2
0
        public void AllChecksPassed()
        {
            var directory = Temp.CreateDirectory();
            var alphaDll  = directory
                            .CreateFile("Alpha.dll")
                            .WriteAllBytes(TestResources.AssemblyLoadTests.Alpha);
            var betaDll = directory
                          .CreateFile("Beta.dll")
                          .WriteAllBytes(TestResources.AssemblyLoadTests.Beta);
            var gammaDll = directory
                           .CreateFile("Gamma.dll")
                           .WriteAllBytes(TestResources.AssemblyLoadTests.Gamma);
            var deltaDll = directory
                           .CreateFile("Delta.dll")
                           .WriteAllBytes(TestResources.AssemblyLoadTests.Delta);

            var analyzerReferences = ImmutableArray.Create(
                new CommandLineAnalyzerReference("Alpha.dll"),
                new CommandLineAnalyzerReference("Beta.dll"),
                new CommandLineAnalyzerReference("Gamma.dll"),
                new CommandLineAnalyzerReference("Delta.dll")
                );

            var result = AnalyzerConsistencyChecker.Check(
                directory.Path,
                analyzerReferences,
                new InMemoryAssemblyLoader(),
                Logger
                );

            Assert.True(result);
        }
예제 #3
0
        public void NetstandardIgnored()
        {
            var          directory = Temp.CreateDirectory();
            const string name      = "netstandardRef";
            var          comp      = CSharpCompilation.Create(
                name,
                new[] { SyntaxFactory.ParseSyntaxTree(@"class C {}") },
                references: new MetadataReference[]
            {
                MetadataReference.CreateFromImage(
                    TestMetadata.ResourcesNetStandard20.netstandard
                    )
            },
                options: new CSharpCompilationOptions(
                    OutputKind.DynamicallyLinkedLibrary,
                    warningLevel: Diagnostic.MaxWarningLevel
                    )
                );
            var compFile = directory.CreateFile(name);

            comp.Emit(compFile.Path);

            var analyzerReferences = ImmutableArray.Create(new CommandLineAnalyzerReference(name));

            var result = AnalyzerConsistencyChecker.Check(
                directory.Path,
                analyzerReferences,
                new InMemoryAssemblyLoader(),
                Logger
                );

            Assert.True(result);
        }
예제 #4
0
        public void MissingReference()
        {
            var directory = Temp.CreateDirectory();
            var alphaDll  = directory.CreateFile("Alpha.dll").WriteAllBytes(TestResources.AssemblyLoadTests.Alpha);

            var analyzerReferences = ImmutableArray.Create(new CommandLineAnalyzerReference("Alpha.dll"));
            var result             = AnalyzerConsistencyChecker.Check(directory.Path, analyzerReferences, new InMemoryAssemblyLoader());

            Assert.False(result);
        }
예제 #5
0
        public void MissingReference()
        {
            var directory = Temp.CreateDirectory();
            var alphaDll  = directory.CopyFile(TestFixture.Alpha.Path);

            var analyzerReferences = ImmutableArray.Create(new CommandLineAnalyzerReference("Alpha.dll"));
            var result             = AnalyzerConsistencyChecker.Check(directory.Path, analyzerReferences, new InMemoryAssemblyLoader(), Logger);

            Assert.True(result);
        }
예제 #6
0
        public void AssemblyLoadException()
        {
            var directory = Temp.CreateDirectory();
            var deltaDll  = directory.CreateFile("Delta.dll").WriteAllBytes(TestResources.AssemblyLoadTests.Delta);

            var analyzerReferences = ImmutableArray.Create(
                new CommandLineAnalyzerReference("Delta.dll"));

            var result = AnalyzerConsistencyChecker.Check(directory.Path, analyzerReferences, TestAnalyzerAssemblyLoader.LoadNotImplemented);

            Assert.False(result);
        }
예제 #7
0
        public void AllChecksPassed()
        {
            var analyzerReferences = ImmutableArray.Create(
                new CommandLineAnalyzerReference("Alpha.dll"),
                new CommandLineAnalyzerReference("Beta.dll"),
                new CommandLineAnalyzerReference("Gamma.dll"),
                new CommandLineAnalyzerReference("Delta.dll"));

            var result = AnalyzerConsistencyChecker.Check(Path.GetDirectoryName(TestFixture.Alpha.Path), analyzerReferences, new InMemoryAssemblyLoader(), Logger);

            Assert.True(result);
        }
예제 #8
0
        public void AssemblyLoadException()
        {
            var directory = Temp.CreateDirectory();

            directory.CopyFile(TestFixture.Delta1.Path);

            var analyzerReferences = ImmutableArray.Create(
                new CommandLineAnalyzerReference("Delta.dll"));

            var result = AnalyzerConsistencyChecker.Check(directory.Path, analyzerReferences, TestAnalyzerAssemblyLoader.LoadNotImplemented, Logger);

            Assert.False(result);
        }
예제 #9
0
        public void DifferingMvids()
        {
            var directory = Temp.CreateDirectory();

            // Load Beta.dll from the future Alpha.dll path to prime the assembly loader
            var alphaDll = directory.CopyFile(TestFixture.Beta.Path, name: "Alpha.dll");

            var assemblyLoader = new InMemoryAssemblyLoader();
            var betaAssembly   = assemblyLoader.LoadFromPath(alphaDll.Path);

            // now overwrite the {directory}/Alpha.dll file with the content from our Alpha.dll test resource
            alphaDll.CopyContentFrom(TestFixture.Alpha.Path);
            directory.CopyFile(TestFixture.Gamma.Path);
            directory.CopyFile(TestFixture.Delta1.Path);

            var analyzerReferences = ImmutableArray.Create(
                new CommandLineAnalyzerReference("Alpha.dll"),
                new CommandLineAnalyzerReference("Gamma.dll"),
                new CommandLineAnalyzerReference("Delta.dll"));

            var result = AnalyzerConsistencyChecker.Check(directory.Path, analyzerReferences, assemblyLoader, Logger);

            Assert.False(result);
        }