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

CA1416 Do not warn for OS dependent messages for creating NotSupportedExceptions #4577

Merged
merged 2 commits into from
Dec 16, 2020

Conversation

buyaa-n
Copy link
Contributor

@buyaa-n buyaa-n commented Dec 15, 2020

Fixes #4545. Related to #4576 raising PR for 5.0.2

@jmarolf this PR is not introducing any new warning, instead reduces false positives, so we decided to merge it to 5.0.2
CC @jeffhandley @mavasani

We should ignore diagnostics in throw statements as they are not platform specific operation and causing false positives, i made sure it ignores exception messages for a block not only just throwing, but having some other statements too, i think this will be more useful for conditional throwing like:

[SupportedOSPlatform("browser")]
public static class SR
{
    public static string Message {get; set;}
    public static void M1() { }
}

public class Test
{
    void ConditionallyThrowWithStringConstructor()
    {
        SR.M1(); // warns 
        if (!OperatingSystem.IsBrowser())
        {
            throw new PlatformNotSupportedException(SR.Message); // not warns
        }
        SR.M1() // not warns
    }
}

@codecov
Copy link

codecov bot commented Dec 15, 2020

Codecov Report

Merging #4577 (fa9d8a1) into release/5.0.2xx (e1f2147) will increase coverage by 0.01%.
The diff coverage is 99.53%.

@@                 Coverage Diff                 @@
##           release/5.0.2xx    #4577      +/-   ##
===================================================
+ Coverage            95.81%   95.82%   +0.01%     
===================================================
  Files                 1187     1164      -23     
  Lines               279520   264656   -14864     
  Branches             20221    15987    -4234     
===================================================
- Hits                267815   253601   -14214     
+ Misses                9593     9024     -569     
+ Partials              2112     2031      -81     

@buyaa-n buyaa-n requested a review from jmarolf December 15, 2020 21:25
@buyaa-n
Copy link
Contributor Author

buyaa-n commented Dec 16, 2020

Seems @jmarolf is out, i am gonna merge it as it is need for fixing some of runtime warnings

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.

3 participants