Пример #1
0
 public void TargetTypeBad()
 {
     var csc = new Csc();
     csc.TargetType = "bad";
     csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
     Assert.Equal("/out:test.exe /target:bad test.cs", csc.GenerateResponseFileContents());
 }
Пример #2
0
 public void TargetTypeDll()
 {
     var csc = new Csc();
     csc.TargetType = "library";
     csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
     Assert.Equal("/out:test.dll /target:library test.cs", csc.GenerateResponseFileContents());
 }
Пример #3
0
        public void NullableReferenceTypes_Default_02()
        {
            var csc = new Csc();

            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());
        }
Пример #4
0
        public void InstrumentTestNamesFlag()
        {
            var csc = new Csc();

            csc.Instrument = "Instrument.This.Flag";
            Assert.Equal("/instrument:Instrument.This.Flag", csc.GenerateResponseFileContents());
        }
Пример #5
0
 public void RefOut()
 {
     var csc = new Csc();
     csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
     csc.OutputRefAssembly = MSBuildUtil.CreateTaskItem("ref\\test.dll");
     Assert.Equal("/out:test.exe /refout:ref\\test.dll test.cs", csc.GenerateResponseFileContents());
 }
Пример #6
0
        public void DisableSdkPath()
        {
            var csc = new Csc();

            csc.DisableSdkPath = true;
            Assert.Equal(@"/nosdkpath", csc.GenerateResponseFileContents());
        }
Пример #7
0
        public void DebugType()
        {
            var csc = new Csc();

            csc.Sources   = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType = "full";
            Assert.Equal("/debug:full /out:test.exe test.cs", csc.GenerateResponseFileContents());

            csc           = new Csc();
            csc.Sources   = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType = "pdbonly";
            Assert.Equal("/debug:pdbonly /out:test.exe test.cs", csc.GenerateResponseFileContents());

            csc           = new Csc();
            csc.Sources   = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType = "portable";
            Assert.Equal("/debug:portable /out:test.exe test.cs", csc.GenerateResponseFileContents());

            csc           = new Csc();
            csc.Sources   = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType = "embedded";
            Assert.Equal("/debug:embedded /out:test.exe test.cs", csc.GenerateResponseFileContents());

            csc           = new Csc();
            csc.Sources   = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType = null;
            Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());

            csc           = new Csc();
            csc.Sources   = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType = "";
            Assert.Equal("/debug: /out:test.exe test.cs", csc.GenerateResponseFileContents());
        }
Пример #8
0
 public void RefOnly()
 {
     var csc = new Csc();
     csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
     csc.RefOnly = true;
     Assert.Equal("/out:test.exe /refonly test.cs", csc.GenerateResponseFileContents());
 }
Пример #9
0
        public void MultipleSourceFiles()
        {
            var csc = new Csc();

            csc.Sources = MSBuildUtil.CreateTaskItems("test1.cs", "test2.cs");
            Assert.Equal("/out:test1.exe test1.cs test2.cs", csc.GenerateResponseFileContents());
        }
Пример #10
0
 public void OutputAssembly()
 {
     var csc = new Csc();
     csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
     csc.OutputAssembly = MSBuildUtil.CreateTaskItem("x.exe");
     Assert.Equal("/out:x.exe test.cs", csc.GenerateResponseFileContents());
 }
Пример #11
0
 public void LangVersionFlag()
 {
     var csc = new Csc();
     csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
     csc.LangVersion = "iso-1";
     Assert.Equal("/out:test.exe /langversion:iso-1 test.cs", csc.GenerateResponseFileContents());
 }
Пример #12
0
        public void Embed()
        {
            var csc = new Csc();

            csc.Sources       = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType     = "portable";
            csc.EmbeddedFiles = MSBuildUtil.CreateTaskItems(@"test.cs", @"test.txt");
            Assert.Equal(@"/debug:portable /out:test.exe /embed:test.cs /embed:test.txt test.cs", csc.GenerateResponseFileContents());

            csc               = new Csc();
            csc.Sources       = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType     = "portable";
            csc.EmbeddedFiles = MSBuildUtil.CreateTaskItems(@"C:\x y\z.json");
            Assert.Equal(@"/debug:portable /out:test.exe /embed:""C:\x y\z.json"" test.cs", csc.GenerateResponseFileContents());

            csc               = new Csc();
            csc.Sources       = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType     = "portable";
            csc.EmbeddedFiles = null;
            Assert.Equal(@"/debug:portable /out:test.exe test.cs", csc.GenerateResponseFileContents());

            csc               = new Csc();
            csc.Sources       = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType     = "full";
            csc.EmbeddedFiles = MSBuildUtil.CreateTaskItems();
            Assert.Equal(@"/debug:full /out:test.exe test.cs", csc.GenerateResponseFileContents());
        }
Пример #13
0
        public void NullableReferenceTypes_Safeonlywarnings()
        {
            var csc = new Csc();

            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.NullableContextOptions = "safeonlywarnings";
            Assert.Equal("/nullable:safeonlywarnings /out:test.exe test.cs", csc.GenerateResponseFileContents());
        }
Пример #14
0
        public void NullableReferenceTypes_NullableWins_Enable(string nullableContextOptions, string nullable)
        {
            var csc = new Csc();

            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.NullableContextOptions = nullableContextOptions;
            csc.Nullable = nullable;
            Assert.Equal("/nullable:enable /out:test.exe test.cs", csc.GenerateResponseFileContents());
        }
Пример #15
0
 public void FeaturesEmpty()
 {
     foreach (var cur in new[] { "", null })
     {
         var csc = new Csc();
         csc.Features = cur;
         csc.Sources  = MSBuildUtil.CreateTaskItems("test.cs");
         Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());
     }
 }
Пример #16
0
        public void PathMapOption()
        {
            var csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.PathMap = "K1=V1,K2=V2";
            Assert.Equal("/pathmap:\"K1=V1,K2=V2\" /out:test.exe test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());
        }
Пример #17
0
        public void RuntimeMetadataVersionFlag()
        {
            var csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.RuntimeMetadataVersion = "v1234";
            Assert.Equal("/out:test.exe /runtimemetadataversion:v1234 test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.RuntimeMetadataVersion = null;
            Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());
        }
Пример #18
0
        public void DefineConstantsSimple()
        {
            Action <string> test = (s) =>
            {
                var csc = new Csc();
                csc.DefineConstants = s;
                csc.Sources         = MSBuildUtil.CreateTaskItems("test.cs");
                Assert.Equal("/define:D1;D2 /out:test.exe test.cs", csc.GenerateResponseFileContents());
            };

            test("D1;D2");
            test("D1,D2");
            test("D1 D2");
        }
Пример #19
0
        public void PublicSignFlag()
        {
            var csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.PublicSign = true;
            Assert.Equal("/out:test.exe /publicsign+ test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.PublicSign = false;
            Assert.Equal("/out:test.exe /publicsign- test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());
        }
Пример #20
0
        public void DeterministicFlag()
        {
            var csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.Deterministic = true;
            Assert.Equal("/out:test.exe /deterministic+ test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.Deterministic = false;
            Assert.Equal("/out:test.exe /deterministic- test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());
        }
Пример #21
0
        public void EmbedAllSources()
        {
            var csc = new Csc();

            csc.Sources         = MSBuildUtil.CreateTaskItems("test.cs");
            csc.EmbeddedFiles   = MSBuildUtil.CreateTaskItems(@"test.cs", @"test.txt");
            csc.EmbedAllSources = true;

            Assert.Equal(@"/out:test.exe /embed /embed:test.cs /embed:test.txt test.cs", csc.GenerateResponseFileContents());

            csc                 = new Csc();
            csc.Sources         = MSBuildUtil.CreateTaskItems("test.cs");
            csc.EmbedAllSources = true;

            Assert.Equal(@"/out:test.exe /embed test.cs", csc.GenerateResponseFileContents());
        }
Пример #22
0
        public void Features()
        {
            Action <string> test = (s) =>
            {
                var csc = new Csc();
                csc.Features = s;
                csc.Sources  = MSBuildUtil.CreateTaskItems("test.cs");
                Assert.Equal("/out:test.exe /features:a /features:b test.cs", csc.GenerateResponseFileContents());
            };

            test("a;b");
            test("a,b");
            test("a b");
            test(",a;b ");
            test(";a;;b;");
            test(",a,,b,");
        }
Пример #23
0
        public void ChecksumAlgorithmOption()
        {
            var csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.ChecksumAlgorithm = "sha256";
            Assert.Equal("/out:test.exe /checksumalgorithm:sha256 test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.ChecksumAlgorithm = null;
            Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.ChecksumAlgorithm = "";
            Assert.Equal("/out:test.exe /checksumalgorithm: test.cs", csc.GenerateResponseFileContents());
        }
Пример #24
0
        public void SkipAnalyzersFlag()
        {
            var csc = new Csc();

            csc.Sources       = MSBuildUtil.CreateTaskItems("test.cs");
            csc.SkipAnalyzers = true;
            Assert.Equal("/out:test.exe /skipanalyzers+ test.cs", csc.GenerateResponseFileContents());

            csc               = new Csc();
            csc.Sources       = MSBuildUtil.CreateTaskItems("test.cs");
            csc.SkipAnalyzers = false;
            Assert.Equal("/out:test.exe /skipanalyzers- test.cs", csc.GenerateResponseFileContents());

            csc         = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());
        }
Пример #25
0
        public void EditorConfig()
        {
            var csc = new Csc();

            csc.Sources             = MSBuildUtil.CreateTaskItems("test.cs");
            csc.AnalyzerConfigFiles = MSBuildUtil.CreateTaskItems(".editorconfig");
            Assert.Equal(@"/out:test.exe /analyzerconfig:.editorconfig test.cs", csc.GenerateResponseFileContents());

            csc                     = new Csc();
            csc.Sources             = MSBuildUtil.CreateTaskItems("test.cs", "subdir\\test.cs");
            csc.AnalyzerConfigFiles = MSBuildUtil.CreateTaskItems(".editorconfig", "subdir\\.editorconfig");
            Assert.Equal(@"/out:test.exe /analyzerconfig:.editorconfig /analyzerconfig:subdir\.editorconfig test.cs subdir\test.cs", csc.GenerateResponseFileContents());

            csc                     = new Csc();
            csc.Sources             = MSBuildUtil.CreateTaskItems("test.cs");
            csc.AnalyzerConfigFiles = MSBuildUtil.CreateTaskItems("..\\.editorconfig", "sub dir\\.editorconfig");
            Assert.Equal(@"/out:test.exe /analyzerconfig:..\.editorconfig /analyzerconfig:""sub dir\.editorconfig"" test.cs", csc.GenerateResponseFileContents());
        }
Пример #26
0
        public void InstrumentTestNamesFlag()
        {
            var csc = new Csc();
            csc.Instrument = null;
            Assert.Equal(string.Empty, csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Instrument = "TestCoverage";
            Assert.Equal("/instrument:TestCoverage", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Instrument = "TestCoverage,Mumble";
            Assert.Equal("/instrument:TestCoverage,Mumble", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Instrument = "TestCoverage,Mumble;Stumble";
            Assert.Equal("/instrument:TestCoverage,Mumble,Stumble", csc.GenerateResponseFileContents());
        }
Пример #27
0
        public void SharedCompilationId()
        {
            var csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.UseSharedCompilation = true;
            csc.SharedCompilationId = "testPipeName";
            Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.UseSharedCompilation = false;
            csc.SharedCompilationId = "testPipeName";
            Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.SharedCompilationId = "testPipeName";
            Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents());
        }
Пример #28
0
        public void SourceLink()
        {
            var csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType = "portable";
            csc.SourceLink = @"C:\x y\z.json";
            Assert.Equal(@"/debug:portable /out:test.exe /sourcelink:""C:\x y\z.json"" test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType = "portable";
            csc.SourceLink = null;
            Assert.Equal(@"/debug:portable /out:test.exe test.cs", csc.GenerateResponseFileContents());

            csc = new Csc();
            csc.Sources = MSBuildUtil.CreateTaskItems("test.cs");
            csc.DebugType = "portable";
            csc.SourceLink = "";
            Assert.Equal(@"/debug:portable /out:test.exe /sourcelink: test.cs", csc.GenerateResponseFileContents());
        }