Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

Description

Updates Roslyn to 5.0.0-2.26070.104 to match the 10.0.1xx SDK. The new analyzer version enforces IDE0071 and IDE0031 more strictly, causing build failures with TreatWarningsAsErrors=true.

Changes

eng/Versions.props

  • Bump MicrosoftCodeAnalysisVersion_LatestVS: 4.14.05.0.0-2.26070.104

.editorconfig (global [*.cs] section)

  • Add dotnet_diagnostic.IDE0071.severity = silent - Suppresses false positives for ReadOnlySpan<char>.ToString() in string interpolations (required for netstandard targets where ReadOnlySpan cannot be directly interpolated)
  • Add dotnet_diagnostic.IDE0031.severity = silent - Suppresses null propagation suggestions

Setting silent severity preserves IDE hints while preventing build errors.

Testing

Resolves build failures in:

  • System.Security.Cryptography.MLDsaCng.Windows.cs
  • System.Security.Cryptography.MLDsaImplementation.Windows.cs
  • System.Reflection.Metadata.TypeNameParser.cs
Original prompt

This is a port of PR #123509 from release/10.0 to main.

Summary

Update MicrosoftCodeAnalysisVersion_LatestVS to match what is referenced in the 10.0.1xx SDK:
https://github.com/dotnet/sdk/blob/0b3258423a96e6b0e0582a31f09e10ce4478fc06/eng/Version.Details.xml#L95

Changes Required

1. eng/Versions.props

Update the MicrosoftCodeAnalysisVersion_LatestVS property from 4.14.0 to 5.0.0-2.26070.104:

-    <MicrosoftCodeAnalysisVersion_LatestVS>4.14.0</MicrosoftCodeAnalysisVersion_LatestVS>
+    <MicrosoftCodeAnalysisVersion_LatestVS>5.0.0-2.26070.104</MicrosoftCodeAnalysisVersion_LatestVS>

2. src/libraries/Common/src/System/Security/Cryptography/MLDsaCng.Windows.cs

Add #pragma warning disable/restore IDE0071 around the Debug.Fail call to fix ReadOnlySpan interpolation for netstandard targets:

+#pragma warning disable IDE0071
                    Debug.Fail(
                        $"{nameof(blobType)}: {blobType}, " +
                        $"{nameof(parameterSet)}: {parameterSet.ToString()}, " +
                        $"{nameof(keyBytes)}.Length: {keyBytes.Length} / {expectedKeySize}");
+#pragma warning restore IDE0071

3. src/libraries/Common/src/System/Security/Cryptography/MLDsaImplementation.Windows.cs

Same change - add #pragma warning disable/restore IDE0071 around the Debug.Fail call:

+#pragma warning disable IDE0071
                    Debug.Fail(
                        $"{nameof(blobType)}: {blobType}, " +
                        $"{nameof(parameterSet)}: {parameterSet.ToString()}, " +
                        $"{nameof(keyBytes)}.Length: {keyBytes.Length} / {expectedKeySize}");
+#pragma warning restore IDE0071

4. src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeNameParser.cs

Add #pragma warning disable/restore IDE0071 around the Debug.Assert call:

+#pragma warning disable IDE0071
            Debug.Assert(parsedName.GetNodeCount() == recursiveDepth, $"Node count mismatch for '{typeName.ToString()}'");
+#pragma warning restore IDE0071

Context

The newer version of Microsoft.CodeAnalysis (5.0.0-2.26070.104) introduces a new analyzer warning IDE0071 (redundant ToString() in string interpolation) that triggers on ReadOnlySpan<char>.ToString() calls in interpolated strings. However, for netstandard targets, these .ToString() calls are required because ReadOnlySpan<char> cannot be directly interpolated. The pragma warnings suppress this false positive while keeping the necessary .ToString() calls.

Related issue: #123503

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

… suppress IDE0071

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot AI changed the title [WIP] Update MicrosoftCodeAnalysisVersion_LatestVS for main branch Update MicrosoftCodeAnalysisVersion_LatestVS to 5.0.0-2.26070.104 Jan 23, 2026
Copilot AI requested a review from agocke January 23, 2026 05:11
.editorconfig Outdated
# disable CA2025, the analyzer throws a NullReferenceException when processing this file: https://github.com/dotnet/roslyn-analyzers/issues/7652
dotnet_diagnostic.CA2025.severity = none

# IDE0071: Simplify interpolation - suppress globally as ReadOnlySpan<char>.ToString() is required for netstandard targets
Copy link
Member

Choose a reason for hiding this comment

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

@copilot No, the reason we want to disable it is because it is an IDE style suggestion, not a code issue. We can keep it as a suggestion, rather than disabling it entirely

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to severity = suggestion in a7dd931.

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
…rors

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot AI changed the title Update MicrosoftCodeAnalysisVersion_LatestVS to 5.0.0-2.26070.104 Update Roslyn to 5.0.0-2.26070.104 and configure IDE0071 severity Jan 23, 2026
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot AI changed the title Update Roslyn to 5.0.0-2.26070.104 and configure IDE0071 severity Update Roslyn to 5.0.0-2.26070.104 and suppress IDE0071 globally Jan 23, 2026
Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copilot AI changed the title Update Roslyn to 5.0.0-2.26070.104 and suppress IDE0071 globally Update Roslyn to 5.0.0-2.26070.104 and suppress IDE0071/IDE0031 Jan 23, 2026
@agocke
Copy link
Member

agocke commented Jan 23, 2026

@sbomer I made a clean upgrade PR here

@agocke agocke marked this pull request as ready for review January 23, 2026 19:56
Copilot AI review requested due to automatic review settings January 23, 2026 19:56
@agocke
Copy link
Member

agocke commented Jan 23, 2026

@jjonescz Can you look to why IDE warnings are suddenly showing up in our build?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Roslyn analyzer version to match the 10.0.1xx SDK and configures the build to handle new analyzer warnings that would otherwise cause build failures when TreatWarningsAsErrors=true is enabled.

Changes:

  • Bump Roslyn/CodeAnalysis from version 4.14.0 to 5.0.0-2.26070.104
  • Suppress IDE0071 (simplify interpolation) and IDE0031 (use null propagation) as silent diagnostics to prevent build errors while preserving IDE hints

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
eng/Versions.props Updates MicrosoftCodeAnalysisVersion_LatestVS to align with 10.0.1xx SDK
.editorconfig Adds silent severity for IDE0071 and IDE0031 to prevent build failures from stricter analyzer enforcement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants