-
-
Notifications
You must be signed in to change notification settings - Fork 844
Correctly handle polyfilled required infrastructure attributes
#1421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9437620
correctly handle polyfilled `required` infrastructure attributes
DoctorVanGogh ec1c53e
fix stylecop errors
DoctorVanGogh 3e617d1
Update src/Autofac/Util/ReflectionExtensions.cs
DoctorVanGogh 685e73c
Update src/Autofac/Util/ReflectionExtensions.cs
DoctorVanGogh f5346a7
add custom required polyfill for tests
DoctorVanGogh e68c1b8
use polyfill copied from dotnet runtime
DoctorVanGogh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,7 @@ | ||
| [*.cs] | ||
| # dont complain about .NET Foundation license header | ||
| dotnet_diagnostic.SA1636.severity = none | ||
| # dont enforce documentation styles for imported shims | ||
| dotnet_diagnostic.SA1623.severity = none | ||
| # dont enforce coding styles for imported shims | ||
| dotnet_diagnostic.SA1502.severity = none |
This file contains hidden or 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,41 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| #if !NET7_0_OR_GREATER | ||
|
|
||
| namespace System.Runtime.CompilerServices | ||
| { | ||
| /// <summary> | ||
| /// Indicates that compiler support for a particular feature is required for the location where this attribute is applied. | ||
| /// </summary> | ||
| [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] | ||
| internal sealed class CompilerFeatureRequiredAttribute : Attribute | ||
| { | ||
| public CompilerFeatureRequiredAttribute(string featureName) | ||
| { | ||
| FeatureName = featureName; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// The name of the compiler feature. | ||
| /// </summary> | ||
| public string FeatureName { get; } | ||
|
|
||
| /// <summary> | ||
| /// If true, the compiler can choose to allow access to the location where this attribute is applied if it does not understand <see cref="FeatureName"/>. | ||
| /// </summary> | ||
| public bool IsOptional { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// The <see cref="FeatureName"/> used for the ref structs C# feature. | ||
| /// </summary> | ||
| public const string RefStructs = nameof(RefStructs); | ||
|
|
||
| /// <summary> | ||
| /// The <see cref="FeatureName"/> used for the required members C# feature. | ||
| /// </summary> | ||
| public const string RequiredMembers = nameof(RequiredMembers); | ||
| } | ||
| } | ||
|
|
||
| #endif |
This file contains hidden or 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,10 @@ | ||
| # shim files for the `required` feature | ||
|
|
||
| Functional polyfill copied from https://github.com/dotnet/runtime[^1] to allow use of `required` keyword in frameworks below .NET7 (if `LangVersion`is set high enough to offer that feature.) | ||
|
|
||
| --- | ||
|
|
||
| [^1]:[SetsRequiredMemberAttribute.cs](https://github.com/dotnet/runtime/blob/c1ab6c5b2524880ed9368841a0a5d8ead78ea09d/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/SetsRequiredMembersAttribute.cs), [RequiredMemberAttribute.cs](https://github.com/dotnet/runtime/blob/c1ab6c5b2524880ed9368841a0a5d8ead78ea09d/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RequiredMemberAttribute.cs), [CompilerFeatureRequiredAttribute.cs](https://github.com/dotnet/runtime/blob/c1ab6c5b2524880ed9368841a0a5d8ead78ea09d/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompilerFeatureRequiredAttribute.cs) | ||
|
|
||
|
|
||
|
|
This file contains hidden or 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,22 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| #if !NET7_0_OR_GREATER | ||
|
|
||
| using System.ComponentModel; | ||
|
|
||
| namespace System.Runtime.CompilerServices | ||
| { | ||
| /// <summary>Specifies that a type has required members or that a member is required.</summary> | ||
| [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] | ||
| [EditorBrowsable(EditorBrowsableState.Never)] | ||
| #if SYSTEM_PRIVATE_CORELIB | ||
| public | ||
| #else | ||
| internal | ||
| #endif | ||
| sealed class RequiredMemberAttribute : Attribute | ||
| { } | ||
| } | ||
|
|
||
| #endif |
This file contains hidden or 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,22 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| #if !NET7_0_OR_GREATER | ||
|
|
||
| namespace System.Diagnostics.CodeAnalysis | ||
| { | ||
| /// <summary> | ||
| /// Specifies that this constructor sets all required members for the current type, and callers | ||
| /// do not need to set any required members themselves. | ||
| /// </summary> | ||
| [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] | ||
| #if SYSTEM_PRIVATE_CORELIB | ||
| public | ||
| #else | ||
| internal | ||
| #endif | ||
| sealed class SetsRequiredMembersAttribute : Attribute | ||
| { } | ||
| } | ||
|
|
||
| #endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.