dotnet / dotnet/dotnet-api-docs

Improve Clarity on what UnsupportedPlatformOS does

Open
#8,766 2 comments 0 reactions 0 assignees View on GitHub
area-System.Runtime Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

The docs for this API attribute never state what happens when the attribute is violated: [UnsupportedPlatformOS](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.versioning.unsupportedosplatformattribute?view=net-7.0)

I think in the remarks we should link to this page, with something like:
`To see what happens when code tries to violate this attribute, see: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1416`.

However, the docs could be improved further. I think it is possible to write a faulty `SupportedOSPlatformGuard`? If that is the case, it's interesting what could happen if code is called on an unsupported OS when the code has the attribute. Does it throw an exception? Is it up to the implementation? I wondered this looking at https://learn.microsoft.com/en-us/dotnet/api/system.console.outputencoding?view=net-7.0. I wasn't sure what would happen if it were possible to build for an unsupported OS, or if it was theoretically possible, which led me here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.