Skip to content

Commit 115a89d

Browse files
authored
Add ExcludeStatics API (#117905)
Add ExcludeStatics API. This property on RequiresUnreferencedCode and RequiresDynamicCode indicates that the annotation should not apply to static members, allowing annotating a type (and suppressing warnings from virtual members) without also annotating the static members.
1 parent d153a7a commit 115a89d

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/RequiresDynamicCodeAttribute.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public RequiresDynamicCodeAttribute(string message)
3030
Message = message;
3131
}
3232

33+
/// <summary>
34+
/// When set to true, indicates that the annotation should not apply to static members.
35+
/// </summary>
36+
public bool ExcludeStatics { get; set; }
37+
3338
/// <summary>
3439
/// Gets a message that contains information about the usage of dynamic code.
3540
/// </summary>

src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/RequiresUnreferencedCodeAttribute.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public RequiresUnreferencedCodeAttribute(string message)
3131
Message = message;
3232
}
3333

34+
/// <summary>
35+
/// When set to true, indicates that the annotation should not apply to static members.
36+
/// </summary>
37+
public bool ExcludeStatics { get; set; }
38+
3439
/// <summary>
3540
/// Gets a message that contains information about the usage of unreferenced code.
3641
/// </summary>

src/libraries/System.Runtime/ref/System.Runtime.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9029,13 +9029,15 @@ public RequiresAssemblyFilesAttribute(string message) { }
90299029
public sealed partial class RequiresDynamicCodeAttribute : System.Attribute
90309030
{
90319031
public RequiresDynamicCodeAttribute(string message) { }
9032+
public bool ExcludeStatics { get; set; }
90329033
public string Message { get { throw null; } }
90339034
public string? Url { get { throw null; } set { } }
90349035
}
90359036
[System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Method, Inherited=false)]
90369037
public sealed partial class RequiresUnreferencedCodeAttribute : System.Attribute
90379038
{
90389039
public RequiresUnreferencedCodeAttribute(string message) { }
9040+
public bool ExcludeStatics { get; set; }
90399041
public string Message { get { throw null; } }
90409042
public string? Url { get { throw null; } set { } }
90419043
}

0 commit comments

Comments
 (0)