Skip to content

Remove non-CLS exceptions handlers and CS1058 suppressions (+ cleanup) #10876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

h3xds1nz
Copy link
Member

@h3xds1nz h3xds1nz commented May 26, 2025

This is blocked by #10874 / #10875, hence draft.

Description

Removes non-CLS exceptions handlers (general catch handler blocks) in LineServicesCallbacks that are never executed (basically a dead-code). This originates from pre-NetFXv2 / C# 2.0 behaviour before non-CLS exceptions were being wrapped by default as RuntimeWrappedException which derives from Exception and hence you needed a general catch handler.

Nowadays Roslyn emits [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] by default so all non-CLS exceptions are already handled via catch (Exception e) blocks and never fallthrough to the general catch { } handler.

Customer Impact

Smaller assembly size, codegen size and cleaner codebase for developers.

Regression

No.

Testing

Local build.

Risk

Low, those would be generally caught by CS1058 but the warning was suppressed. Reviewers just need to make sure the removed blocks are preceeded by catch (Exception e) to achieve the same effect.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested a review from a team as a code owner May 26, 2025 09:12
@h3xds1nz h3xds1nz marked this pull request as draft May 26, 2025 09:13
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions draft PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant