예제 #1
0
        public void TestDiscoverEditorConfigFiles()
        {
            var srcFile           = ProjectDir.CreateFile("lib1.cs").WriteAllText("class C { }");
            var subdir            = ProjectDir.CreateDirectory("subdir");
            var srcFile2          = subdir.CreateFile("lib2.cs").WriteAllText("class D { }");
            var editorConfigFile2 = subdir.CreateFile(".editorconfig").WriteAllText(@"[*.cs]
some_prop = some_val");

            VerifyValues(
                customProps: null,
                customTargets: null,
                targets: new[]
            {
                "CoreCompile"
            },
                expressions: new[]
            {
                "@(EditorConfigFiles)"
            },
                expectedResults: new[]
            {
                Path.Combine(ProjectDir.Path, ".editorconfig"),
                editorConfigFile2.Path
            });
        }
예제 #2
0
        public void TestDiscoverGlobalConfigFilesWhenEditorConfigDisabled()
        {
            var srcFile           = ProjectDir.CreateFile("lib1.cs").WriteAllText("class C { }");
            var globalConfigFile  = ProjectDir.CreateFile(".globalconfig").WriteAllText(@"is_global = true
some_prop = some_val");
            var subdir            = ProjectDir.CreateDirectory("subdir");
            var srcFile2          = subdir.CreateFile("lib2.cs").WriteAllText("class D { }");
            var globalConfigFile2 = subdir.CreateFile(".globalconfig").WriteAllText(@"is_global = true
some_prop = some_val");

            VerifyValues(
                customProps: @"
<PropertyGroup>
    <DiscoverEditorConfigFiles>false</DiscoverEditorConfigFiles>
</PropertyGroup>",
                customTargets: null,
                targets: new[]
            {
                "CoreCompile"
            },
                expressions: new[]
            {
                "@(EditorConfigFiles)"
            },
                expectedResults: AppendExtraEditorConfigs(new[]
            {
                globalConfigFile.Path,
                globalConfigFile2.Path
            }, findEditorConfigs: false));
        }
예제 #3
0
        public void TestDiscoverEditorAndGlobalConfigFilesCanBeDisabled()
        {
            var srcFile           = ProjectDir.CreateFile("lib1.cs").WriteAllText("class C { }");
            var globalConfigFile  = ProjectDir.CreateFile(".globalconfig").WriteAllText(@"is_global = true
some_prop = some_val");
            var subdir            = ProjectDir.CreateDirectory("subdir");
            var globalConfigFile2 = subdir.CreateFile(".globalconfig").WriteAllText(@"is_global = true
some_prop = some_val");

            VerifyValues(
                customProps: @"
<PropertyGroup>
    <DiscoverEditorConfigFiles>false</DiscoverEditorConfigFiles>
    <DiscoverGlobalAnalyzerConfigFiles>false</DiscoverGlobalAnalyzerConfigFiles>
</PropertyGroup>",
                customTargets: null,
                targets: new[]
            {
                "CoreCompile"
            },
                expressions: new[]
            {
                "@(EditorConfigFiles)"
            },
                expectedResults: new[] { "" });
        }
예제 #4
0
        public void TestDiscoverGlobalConfigFilesCanBeDisabled()
        {
            var srcFile           = ProjectDir.CreateFile("lib1.cs").WriteAllText("class C { }");
            var globalConfigFile  = ProjectDir.CreateFile(".globalconfig").WriteAllText(@"is_global = true
some_prop = some_val");
            var subdir            = ProjectDir.CreateDirectory("subdir");
            var srcFile2          = subdir.CreateFile("lib2.cs").WriteAllText("class D { }");
            var globalConfigFile2 = subdir.CreateFile(".globalconfig").WriteAllText(@"is_global = true
some_prop = some_val");

            VerifyValues(
                customProps: @"
<PropertyGroup>
  <DiscoverGlobalAnalyzerConfigFiles>false</DiscoverGlobalAnalyzerConfigFiles>
  <!-- Disable automatic global .editorconfig generation by the SDK --> 
  <GenerateMSBuildEditorConfigFile>false</GenerateMSBuildEditorConfigFile>
</PropertyGroup>",
                customTargets: null,
                targets: new[]
            {
                "CoreCompile"
            },
                expressions: new[]
            {
                "@(EditorConfigFiles)"
            },
                expectedResults: AppendExtraEditorConfigs(new[]
            {
                Path.Combine(ProjectDir.Path, ".editorconfig"),
            }, findGlobalConfigs: false));
        }