dotnet / dotnet/dotnet-api-docs
All alternatives of an attribute with FrameworkAlternate are shown regardless of framework selected
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
I discovered this when I was reading up on the SecuritySafeCriticalAttribute class on
https://docs.microsoft.com/en-us/dotnet/api/system.security.securitysafecriticalattribute?view=netframework-4.8. This class have the following code snippet which does not make sense since there can only be one `AttributeUsage` on a class.
```csharp
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Enum | System.AttributeTargets.Constructor | System.AttributeTargets.Method | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Delegate, AllowMultiple=false, Inherited=false)]
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Struct, AllowMultiple=false, Inherited=false)]
[System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=false, Inherited=false)]
public sealed class SecuritySafeCriticalAttribute : Attribute
```
Examining the "code-behind" - https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Security/SecuritySafeCriticalAttribute.xml - reveals that each `AttributeUsage` is for a different moniker. I would have expected that changing the product and version on the page would effect the code snippet such that only the relevant `AttributeUsage` was shown. As it is now one can only know the correct `AttributeUsage` by examining the xml file.
Contributor guide
Assessment
This issue has not been assessed yet.