Skip to content
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

Support all Debug.Assert(...) overloads in flow analysis #5764

Merged
merged 2 commits into from
Jan 14, 2022

Conversation

buyaa-n
Copy link
Member

@buyaa-n buyaa-n commented Dec 10, 2021

Fixes #5403

Flow analysis doesn't support Debug.Assert(bool, string? message) or any other overload except Debug.Assert(bool):

void M1()
{
    Debug.Assert(OperatingSystem.IsWindows(), "Only supported on windows");
    WindowsOnly(); // warns even not supposed to

    Debug.Assert(OperatingSystem.IsWindows());
    WindowsOnly(); // not warn
}

[SupportedOSPlatform("windows")]
void WindwosOnly () { }

I believe all overloads of Debug.Assert(...) should be supported cc @mavasani

@buyaa-n buyaa-n requested a review from a team as a code owner December 10, 2021 19:49
@codecov
Copy link

codecov bot commented Dec 10, 2021

Codecov Report

Merging #5764 (18615e0) into main (8cc85d9) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5764      +/-   ##
==========================================
+ Coverage   95.56%   95.57%   +0.01%     
==========================================
  Files        1281     1283       +2     
  Lines      296017   296777     +760     
  Branches    18050    18096      +46     
==========================================
+ Hits       282874   283658     +784     
+ Misses      10709    10667      -42     
- Partials     2434     2452      +18     

@buyaa-n
Copy link
Member Author

buyaa-n commented Jan 14, 2022

Perf failure unrelated, filed an issue, mergin the PR

@buyaa-n buyaa-n merged commit a6e8e98 into dotnet:main Jan 14, 2022
@buyaa-n buyaa-n deleted the assert-with-message branch January 14, 2022 01:03
@github-actions github-actions bot added this to the vNext milestone Jan 14, 2022
/// Checks if the method is an overload of the <see cref="Debug.Assert(bool)"/> method.
/// </summary>
/// <param name="method">The IMethodSymbol to test.</param>
/// <returns>True if the method is an overlaod of the <see cref="Debug.Assert(bool)"/> method.</returns>
Copy link
Contributor

Choose a reason for hiding this comment

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

/// <returns>True if the method is an overload of the <see cref="Debug.Assert(bool)"/> method.</returns> :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CA1416 doesn't support Debug.Assert(bool, string? message)
6 participants