dotnet / platform-compat

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

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

Open Basanagoudaglb opened 5 years ago

Basanagoudaglb commented 5 years ago

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

svick commented 5 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(…);