Skip to content

Commit

Permalink
Upgrade MicrosoftCodeAnalysisVersion_LatestVS version to 4.7.0 (#91006)
Browse files Browse the repository at this point in the history
* Upgrade MicrosoftCodeAnalysisVersion_LatestVS version to 4.7.0

* Fix IDE issue with ILLink.RoslynAnalyzer

* Remove source build allowed prebuilt entry for version 4.5.0

* Add tracking issue links
  • Loading branch information
layomia authored Aug 24, 2023
1 parent adbeca2 commit c4f8c3b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 3 deletions.
1 change: 0 additions & 1 deletion eng/SourceBuildPrebuiltBaseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<UsagePattern IdentityGlob="System.Composition*/*6.*" />
<UsagePattern IdentityGlob="System.Composition*/*7.*" />
<UsagePattern IdentityGlob="Microsoft.CodeAnalysis*/*4.4.*" />
<UsagePattern IdentityGlob="Microsoft.CodeAnalysis*/*4.5.*" />
<UsagePattern IdentityGlob="Microsoft.CodeAnalysis*/*4.7.*" />

<!-- Allowed and pinned to major version due to https://github.com/dotnet/source-build/issues/3228 -->
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
Source-build builds the product with the most recent previously source-built release. Thankfully, these two requirements line up nicely
such that any version that satisfies the VS version requirement will also satisfy the .NET SDK version requirement because of how we ship.
-->
<MicrosoftCodeAnalysisVersion_LatestVS>4.5.0</MicrosoftCodeAnalysisVersion_LatestVS>
<MicrosoftCodeAnalysisVersion_LatestVS>4.7.0</MicrosoftCodeAnalysisVersion_LatestVS>
<!-- Some of the analyzer dependencies used by ILLink project -->
<MicrosoftCodeAnalysisBannedApiAnalyzersVersion>3.3.5-beta1.23270.2</MicrosoftCodeAnalysisBannedApiAnalyzersVersion>
</PropertyGroup>
Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/tools/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,15 @@
<Optimize Condition="'$(Optimize)' == ''">true</Optimize>
<DefineConstants>DEBUG;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<!--
These packages affect the design-time experience in VS, we update them
at the same cadance as the MicrosoftCodeAnalysisVersion_LatestVS version.
This property is set eng/Versions.props but we override it because the current
version 4.7.0 flags several warnings that need area-owner expertise to resolve.
TODO: https://github.com/dotnet/runtime/issues/91028.
-->
<PropertyGroup>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>4.5.0</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.7.0-3.23314.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisVersion_LatestVS)" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ private static async Task<Document> ConvertToSourceGenerator(Document document,
// it in as a parameter. If the user specified IgnoreCase, but also selected CultureInvariant, then we skip as the default is to use Invariant culture.
if ((regexOptions & RegexOptions.IgnoreCase) != 0 && (regexOptions & RegexOptions.CultureInvariant) == 0)
{
#pragma warning disable RS1035 // The symbol 'CultureInfo.CurrentCulture' is banned for use by analyzers.
// If CultureInvariant wasn't specified as options, we default to the current culture.
cultureNameValue = generator.LiteralExpression(CultureInfo.CurrentCulture.Name);
#pragma warning restore RS1035

// If options weren't passed in, then we need to define it as well in order to use the three parameter constructor.
regexOptionsValue ??= generator.MemberAccessExpression(SyntaxFactory.IdentifierName("RegexOptions"), "None");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ private RegexParser(string pattern, RegexOptions options, CultureInfo culture, H

/// <summary>Gets the culture to use based on the specified options.</summary>
internal static CultureInfo GetTargetCulture(RegexOptions options) =>
#pragma warning disable RS1035 // The symbol 'CultureInfo.CurrentCulture' is banned for use by analyzers.
(options & RegexOptions.CultureInvariant) != 0 ? CultureInfo.InvariantCulture : CultureInfo.CurrentCulture;
#pragma warning restore RS1035

public static RegexOptions ParseOptionsInPattern(string pattern, RegexOptions options)
{
Expand Down Expand Up @@ -134,7 +136,9 @@ public static RegexTree Parse(string pattern, RegexOptions options, CultureInfo
/// <summary>This static call constructs a flat concatenation node given a replacement pattern.</summary>
public static RegexReplacement ParseReplacement(string pattern, RegexOptions options, Hashtable caps, int capsize, Hashtable capnames)
{
#pragma warning disable RS1035 // The symbol 'CultureInfo.CurrentCulture' is banned for use by analyzers.
CultureInfo culture = (options & RegexOptions.CultureInvariant) != 0 ? CultureInfo.InvariantCulture : CultureInfo.CurrentCulture;
#pragma warning restore RS1035
using var parser = new RegexParser(pattern, options, culture, caps, capsize, capnames, stackalloc int[OptionStackDefaultSize]);

RegexNode root = parser.ScanReplacement();
Expand Down
11 changes: 11 additions & 0 deletions src/tools/illink/src/ILLink.RoslynAnalyzer/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,15 @@
</PropertyGroup>

<Import Project="..\Directory.Build.props" />

<!--
These packages affect the design-time experience in VS, we update them
at the same cadance as the MicrosoftCodeAnalysisVersion_LatestVS version.
This property is set eng/Versions.props but we override it because the current
version 4.7.0 flags several warnings that need area-owner expertise to resolve.
TODO: https://github.com/dotnet/runtime/issues/91030.
-->
<PropertyGroup>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>4.5.0</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
</PropertyGroup>
</Project>

0 comments on commit c4f8c3b

Please sign in to comment.