Repository navigation
Conversation
h3xds1nz
marked this pull request as draft
May 26, 2025 09:13
dotnet-policy-service
Bot
requested review from
Kuldeep-MS,
dipeshmsft and
singhashish-wpf
May 26, 2025 09:13
17 of 34 tasks
oysteinkrog
pushed a commit
to InitialForce/wpf
that referenced
this pull request
Apr 29, 2026
Cherry-pick eb72275 ("Remove warning suppressions") removed CS1058 from PresentationCore.csproj's NoWarn list, but the matching non-CLS catch removal in ElementUtil.cs (paired with upstream PR dotnet#10876) was not part of the cherry-picked commit. The dangling empty catch is unreachable in modern .NET (RuntimeCompatibility wraps non-CLS throws in RuntimeWrappedException, which derives from Exception and is caught by the preceding `catch (Exception e)`), so the only consequence of keeping it was the CS1058 build error. Mirror the same cleanup upstream applied to LineServicesCallbacks (PR dotnet#10874), PtsHost (PR dotnet#10875), and the other PTS callbacks (PR dotnet#10876): delete the empty `catch { }` block. Behaviour change: a non-CLS throw is now rethrown as RuntimeWrappedException instead of being silently swallowed (previous code set remoteException=null which suppressed the rethrow at the call site). Strictly safer. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is blocked by #10874 / #10875, hence draft.
Description
Removes non-CLS exceptions handlers (general catch handler blocks) in
LineServicesCallbacksthat are never executed (basically a dead-code). This originates from pre-NetFXv2/C# 2.0behaviour before non-CLS exceptions were being wrapped by default asRuntimeWrappedExceptionwhich derives fromExceptionand hence you needed a generalcatchhandler.Nowadays Roslyn emits
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]by default so all non-CLS exceptions are already handled viacatch (Exception e)blocks and never fallthrough to the generalcatch { }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