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

Platform compatibility analyzer crashes for some platform attributes combinations #5936

Closed
buyaa-n opened this issue Mar 30, 2022 · 1 comment · Fixed by #5937
Closed

Platform compatibility analyzer crashes for some platform attributes combinations #5936

buyaa-n opened this issue Mar 30, 2022 · 1 comment · Fixed by #5937

Comments

@buyaa-n
Copy link
Member

buyaa-n commented Mar 30, 2022

Platform compatibility analyzer crashes for some platform attributes combinations

Diagnostic ID: CA1416: Validate Platform compatibility

Analyzer source

SDK: Built-in CA analyzers in .NET 5 SDK or later

Version: Any version above SDK 5.0.100

Describe the bug

Test code to repro:

using System.Runtime.Versioning;

[SupportedOSPlatform("ios10.0")]
static class Program
{
    public static void Main()
    {
        Some.Api1(); // should warn
    }
}

[SupportedOSPlatform("ios10.0")]
[SupportedOSPlatform("tvos10.0")]
[SupportedOSPlatform("macos10.14")]
[SupportedOSPlatform("maccatalyst13.1")]
[UnsupportedOSPlatform("watchos")]
class Some
{
    [UnsupportedOSPlatform("watchos")]
    [UnsupportedOSPlatform("tvos")]
    [UnsupportedOSPlatform("macos")]
    [SupportedOSPlatform("ios14.0")]
    public static void Api1() {}
}

Steps To Reproduce

  1. Copy above code in env where CA1416 is enabled
  2. Build it
  3. Build occasionally fails/crashes

Expected behavior

Should see CA1416 warning

Actual behavior

Build sometimes crushes with AD0001 error

 Analyzer 'Microsoft.NetCore.Analyzers.InteropServices.PlatformCompatibilityAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. 

Related to dotnet/maui#823

@buyaa-n
Copy link
Member Author

buyaa-n commented Mar 30, 2022

CC @jeffhandley

@buyaa-n buyaa-n changed the title Platform compatibility analyzer crushes for some platform attributes combinations Platform compatibility analyzer crashes for some platform attributes combinations Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant