File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed
Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 5757 <PropertyGroup Condition =" '$(UseSharedCompilation)' == ''" >
5858 <UseSharedCompilation >true</UseSharedCompilation >
5959 </PropertyGroup >
60+
61+ <!-- Embed EditorConfigFiles into the binary log. This is done here (rather than a static ItemGroup)
62+ to ensure EditorConfigFiles added by analyzer packages in BeforeTargets="CoreCompile" targets
63+ (e.g. NetAnalyzers, CodeStyle) are captured. -->
64+ <ItemGroup >
65+ <EmbedInBinlog Include =" @(EditorConfigFiles)" />
66+ </ItemGroup >
6067 </Target >
6168
6269 <!--
145152 <GlobalAnalyzerConfigFiles Include =" @(_AllDirectoriesAbove->'%(FullPath)'->Distinct()->Combine('.globalconfig'))" Condition =" '$(DiscoverGlobalAnalyzerConfigFiles)' != 'false'" />
146153 <EditorConfigFiles Include =" @(GlobalAnalyzerConfigFiles->Exists())" Condition =" '$(DiscoverGlobalAnalyzerConfigFiles)' != 'false'" />
147154
148- <EmbedInBinlog Include =" @(EditorConfigFiles)" />
149155 </ItemGroup >
150156
151157 <!--
Original file line number Diff line number Diff line change @@ -654,5 +654,44 @@ public void TestGlobalConfigsCanBeManuallyAdded()
654654 "mycustom.config"
655655 } ) ) ;
656656 }
657+
658+ [ ConditionalFact ( typeof ( DotNetSdkAvailable ) , typeof ( WindowsOnly ) , Reason = "https://github.com/dotnet/roslyn/issues/61017" ) ]
659+ public void TestEditorConfigFilesAddedByAnalyzerPackagesAreEmbeddedInBinlog ( )
660+ {
661+ // Simulate the behavior of analyzer packages (e.g., NetAnalyzers, CodeStyle) that add
662+ // EditorConfigFiles in a target that runs BeforeTargets="CoreCompile". Verify those files
663+ // are included in @(EmbedInBinlog) so they are captured in the binary log.
664+ var srcFile = ProjectDir . CreateFile ( "lib1.cs" ) . WriteAllText ( "class C { }" ) ;
665+ var analyzerGlobalConfig = ProjectDir . CreateFile ( "analyzer.globalconfig" ) . WriteAllText ( @"is_global = true
666+ some_prop = some_val" ) ;
667+
668+ VerifyValues (
669+ customProps : @"
670+ <PropertyGroup>
671+ <!-- Disable automatic global .editorconfig generation by the SDK -->
672+ <GenerateMSBuildEditorConfigFile>false</GenerateMSBuildEditorConfigFile>
673+ </PropertyGroup>" ,
674+ customTargets : $@ "
675+ <!-- Simulate an analyzer package (e.g. NetAnalyzers) adding an EditorConfigFile
676+ in a target that runs before CoreCompile. -->
677+ <Target Name=""AddAnalyzerPackageEditorConfigFile"" BeforeTargets=""CoreCompile"">
678+ <ItemGroup>
679+ <EditorConfigFiles Include=""{ analyzerGlobalConfig . Path } "" />
680+ </ItemGroup>
681+ </Target>" ,
682+ targets : new [ ]
683+ {
684+ "CoreCompile"
685+ } ,
686+ expressions : new [ ]
687+ {
688+ "@(EmbedInBinlog)"
689+ } ,
690+ expectedResults : AppendExtraEditorConfigs ( new [ ]
691+ {
692+ Path . Combine ( ProjectDir . Path , ".editorconfig" ) ,
693+ analyzerGlobalConfig . Path
694+ } ) ) ;
695+ }
657696 }
658697}
You can’t perform that action at this time.
0 commit comments