forked from autofac/Autofac
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experimental Initial Member-Level Trimming Support
- Loading branch information
1 parent
08e08bc
commit e7ca457
Showing
6 changed files
with
156 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
// Copyright (c) Autofac Project. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
#pragma warning disable SA1649 // File name should match first type name | ||
#pragma warning disable SA1402 // File may only contain a single type | ||
#if !NET5_0 | ||
|
||
namespace System.Diagnostics.CodeAnalysis | ||
{ | ||
/// <summary> | ||
/// Fake version for pre-net-5.0 targets. | ||
/// </summary> | ||
internal enum DynamicallyAccessedMemberTypes | ||
{ | ||
/// <summary> | ||
/// Specifies the default, parameterless public constructor. | ||
/// </summary> | ||
PublicParameterlessConstructor = 0x0001, | ||
|
||
/// <summary> | ||
/// Specifies all public constructors. | ||
/// </summary> | ||
PublicConstructors = 0x0002 | PublicParameterlessConstructor, | ||
|
||
/// <summary> | ||
/// Specifies all non-public constructors. | ||
/// </summary> | ||
NonPublicConstructors = 0x0004, | ||
|
||
/// <summary> | ||
/// Specifies all public methods. | ||
/// </summary> | ||
PublicMethods = 0x0008, | ||
|
||
/// <summary> | ||
/// Specifies all non-public methods. | ||
/// </summary> | ||
NonPublicMethods = 0x0010, | ||
|
||
/// <summary> | ||
/// Specifies all public fields. | ||
/// </summary> | ||
PublicFields = 0x0020, | ||
|
||
/// <summary> | ||
/// Specifies all non-public fields. | ||
/// </summary> | ||
NonPublicFields = 0x0040, | ||
|
||
/// <summary> | ||
/// Specifies all public nested types. | ||
/// </summary> | ||
PublicNestedTypes = 0x0080, | ||
|
||
/// <summary> | ||
/// Specifies all non-public nested types. | ||
/// </summary> | ||
NonPublicNestedTypes = 0x0100, | ||
|
||
/// <summary> | ||
/// Specifies all public properties. | ||
/// </summary> | ||
PublicProperties = 0x0200, | ||
|
||
/// <summary> | ||
/// Specifies all non-public properties. | ||
/// </summary> | ||
NonPublicProperties = 0x0400, | ||
|
||
/// <summary> | ||
/// Specifies all public events. | ||
/// </summary> | ||
PublicEvents = 0x0800, | ||
|
||
/// <summary> | ||
/// Specifies all non-public events. | ||
/// </summary> | ||
NonPublicEvents = 0x1000, | ||
} | ||
|
||
/// <summary> | ||
/// Fake attribute for older versions. | ||
/// </summary> | ||
[AttributeUsage( | ||
AttributeTargets.Field | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | | ||
AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Method, | ||
Inherited = false)] | ||
internal sealed class DynamicallyAccessedMembersAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DynamicallyAccessedMembersAttribute"/> class | ||
/// with the specified member types. | ||
/// </summary> | ||
/// <param name="memberTypes">The types of members dynamically accessed.</param> | ||
public DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes memberTypes) | ||
{ | ||
MemberTypes = memberTypes; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the <see cref="DynamicallyAccessedMemberTypes"/> which specifies the type | ||
/// of members dynamically accessed. | ||
/// </summary> | ||
public DynamicallyAccessedMemberTypes MemberTypes { get; } | ||
} | ||
|
||
/// <summary> | ||
/// Indicates that the specified method requires dynamic access to code that is not referenced | ||
/// statically, for example through <see cref="System.Reflection"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// This allows tools to understand which methods are unsafe to call when removing unreferenced | ||
/// code from an application. | ||
/// </remarks> | ||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)] | ||
public sealed class RequiresUnreferencedCodeAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RequiresUnreferencedCodeAttribute"/> class | ||
/// with the specified message. | ||
/// </summary> | ||
/// <param name="message"> | ||
/// A message that contains information about the usage of unreferenced code. | ||
/// </param> | ||
public RequiresUnreferencedCodeAttribute(string message) | ||
{ | ||
Message = message; | ||
} | ||
|
||
/// <summary> | ||
/// Gets a message that contains information about the usage of unreferenced code. | ||
/// </summary> | ||
public string Message { get; } | ||
|
||
/// <summary> | ||
/// Gets or sets an optional URL that contains more information about the method, | ||
/// why it requries unreferenced code, and what options a consumer has to deal with it. | ||
/// </summary> | ||
public string? Url { get; set; } | ||
} | ||
} | ||
|
||
#endif |