dotnet / platform-compat

Roslyn analyzer that finds usages of APIs that will throw PlatformNotSupportedException on certain platforms.
MIT License
278 stars 45 forks source link

PC001: Thread.SetApartmentState(ApartmentState) isn't supported on Linux and macOS #221

Open Basanagoudaglb opened 4 years ago

Basanagoudaglb commented 4 years ago

I want my application to be supported in Linux and macOS any suggestions would be appreciated

svick commented 4 years ago

Why do you call SetApartmentState? If you need to call it on Windows only, you could achieve that by changing your code to something like:

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
    Thread.SetApartmentState(…);