Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/CodeStyle/Tools/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ static string GetTargetContents(string language)
<Target Name="AddGlobalAnalyzerConfigForPackage_MicrosoftCodeAnalysis{language}CodeStyle" BeforeTargets="GenerateMSBuildEditorConfigFileCore;CoreCompile" Condition="'$(SkipGlobalAnalyzerConfigForPackage)' != 'true'">
<!-- PropertyGroup to compute global analyzer config file to be used -->
<PropertyGroup>
<_IncludeStyleConfiguration>false</_IncludeStyleConfiguration>
<!-- Check whether 'Style' Level or Mode were configured separate from AnalysisLevel and AnalysisMode. -->
<_IncludeStyleConfiguration Condition="'$(AnalysisLevelStyle)' != '' Or '$(AnalysisModeStyle)' != ''">true</_IncludeStyleConfiguration>
Comment thread
JoeRobich marked this conversation as resolved.

<!-- Default 'AnalysisLevelStyle' to the core 'AnalysisLevel' -->
<AnalysisLevelStyle Condition="'$(AnalysisLevelStyle)' == ''">$(AnalysisLevel)</AnalysisLevelStyle>

Expand Down Expand Up @@ -241,6 +245,10 @@ and an implied numerical option (such as '4') -->
<EffectiveAnalysisLevelStyle Condition="'$(EffectiveAnalysisLevelStyle)' == '' And
'$(AnalysisLevelStyle)' != ''">$(AnalysisLevelStyle)</EffectiveAnalysisLevelStyle>

<!-- Check whether the analysis level is high enough that we should include the analyzer configuration.
From .NET 12, the global config is systematically added if the file exists. Please check https://github.com/dotnet/roslyn/pull/71173 for more info. -->
<_IncludeStyleConfiguration Condition="'$(EffectiveAnalysisLevelStyle)' != '' and $([MSBuild]::VersionGreaterThanOrEquals('$(EffectiveAnalysisLevelStyle)', '12.0'))">true</_IncludeStyleConfiguration>
Comment on lines +248 to +250

<!-- Set the default analysis mode, if not set by the user -->
<_GlobalAnalyzerConfigAnalysisMode_MicrosoftCodeAnalysis{language}CodeStyle>$(AnalysisModeStyle)</_GlobalAnalyzerConfigAnalysisMode_MicrosoftCodeAnalysis{language}CodeStyle>
<_GlobalAnalyzerConfigAnalysisMode_MicrosoftCodeAnalysis{language}CodeStyle Condition="'$(_GlobalAnalyzerConfigAnalysisMode_MicrosoftCodeAnalysis{language}CodeStyle)' == ''">$(AnalysisLevelSuffixStyle)</_GlobalAnalyzerConfigAnalysisMode_MicrosoftCodeAnalysis{language}CodeStyle>
Expand All @@ -255,9 +263,8 @@ and an implied numerical option (such as '4') -->
<_GlobalAnalyzerConfigFile_MicrosoftCodeAnalysis{language}CodeStyle Condition="'$(_GlobalAnalyzerConfigFileName_MicrosoftCodeAnalysis{language}CodeStyle)' != ''">$(_GlobalAnalyzerConfigDir_MicrosoftCodeAnalysis{language}CodeStyle)\$(_GlobalAnalyzerConfigFileName_MicrosoftCodeAnalysis{language}CodeStyle)</_GlobalAnalyzerConfigFile_MicrosoftCodeAnalysis{language}CodeStyle>
</PropertyGroup>

<!-- From .NET 11, the global config is systematically added if the file exists. Please check https://github.com/dotnet/roslyn/pull/71173 for more info. -->
<ItemGroup Condition="Exists('$(_GlobalAnalyzerConfigFile_MicrosoftCodeAnalysis{language}CodeStyle)') and
('$(AnalysisLevelStyle)' != '$(AnalysisLevel)' or '$(AnalysisModeStyle)' != '$(AnalysisMode)' or ('$(EffectiveAnalysisLevelStyle)' != '' and $([MSBuild]::VersionGreaterThanOrEquals('$(EffectiveAnalysisLevelStyle)', '11.0'))))">

@JoeRobich JoeRobich Oct 2, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As brought up in this comment #63036 (comment), the condition would exclude users who had the following configuration despite configuring AnalysisLevelStyle directly.

    <AnalysisLevel>latest-all</AnalysisLevel>
    <AnalysisLevelStyle>latest-all</AnalysisLevelStyle>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that we will start warning in these scenarios? Should we document this as a breaking change?

<!-- Add the analyzer configuration. -->
<ItemGroup Condition="Exists('$(_GlobalAnalyzerConfigFile_MicrosoftCodeAnalysis{language}CodeStyle)') and '$(_IncludeStyleConfiguration)' == 'true'">
<EditorConfigFiles Include="$(_GlobalAnalyzerConfigFile_MicrosoftCodeAnalysis{language}CodeStyle)" />
</ItemGroup>

Expand Down