-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add linker annotations for System.Text.Json #38595
Conversation
src/libraries/System.Text.Json/tests/TrimmingTests/EnumConverterTest.cs
Outdated
Show resolved
Hide resolved
...ext.Json/tests/TrimmingTests/SerializerEntryPoint/DeserializeAsync.FromStream.TypedObject.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.Json/tests/TrimmingTests/System.Text.Json.TrimmingTests.proj
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.Span.cs
Show resolved
Hide resolved
...ibraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Write.Helpers.cs
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonStringEnumConverter.cs
Show resolved
Hide resolved
...Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableConverterFactory.cs
Outdated
Show resolved
Hide resolved
...c/System/Text/Json/Serialization/Converters/Collection/IEnumerableConverterFactoryHelpers.cs
Outdated
Show resolved
Hide resolved
0b34849
to
2f61fcc
Compare
@@ -26,7 +26,12 @@ namespace System.Diagnostics.CodeAnalysis | |||
AttributeTargets.Field | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | | |||
AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Method, | |||
Inherited = false)] | |||
public sealed class DynamicallyAccessedMembersAttribute : Attribute | |||
#if SYSTEM_PRIVATE_CORELIB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I understand why you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand why you need it now. I'm not sure I agree with what we are doing here to be honest, but I'm fine if that is the direction we are going to take.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is the direction we've decided to take. See #36656 (comment)
The other attributes in this folder already have it:
Lines 17 to 22 in 8126962
#if SYSTEM_PRIVATE_CORELIB | |
public | |
#else | |
internal | |
#endif | |
sealed class DynamicDependencyAttribute : Attribute |
Lines 9 to 14 in 8126962
#if INTERNAL_NULLABLE_ATTRIBUTES | |
internal | |
#else | |
public | |
#endif | |
sealed class AllowNullAttribute : Attribute { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, honestly I don't fully agree with this approach (as opposed to having them available down level) since we probably want to allow library developers that target netstandard or < .NET5.0 to be able to annotate their libraries as well, specially if these will be libraries used for blazor wasm. Given the attribute implementation is fully netstandard2.0 compatible, I would opt instead for having compatibility packs (similar to what we did with AsyncInterfaces) for shipping the attributes down level so that we a) don't have to compile these attributes internally on a bunch of libraries and b) allow third party library writters to consume them. I don't want to push to much on doing this but just wanted to share my opinion 😄 cc: @stephentoub
...c/System/Text/Json/Serialization/Converters/Collection/IEnumerableConverterFactoryHelpers.cs
Outdated
Show resolved
Hide resolved
...on/tests/TrimmingTests/CollectionConverters/CollectionConvertersTest.IImmutableDictionary.cs
Outdated
Show resolved
Hide resolved
...ies/System.Text.Json/src/System/Text/Json/Serialization/Attributes/JsonConverterAttribute.cs
Show resolved
Hide resolved
...c/System/Text/Json/Serialization/Converters/Collection/IEnumerableConverterFactoryHelpers.cs
Outdated
Show resolved
Hide resolved
...tem.Text.Json/tests/TrimmingTests/SerializerEntryPoint/Deserialize.FromReader.BoxedObject.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Merging per @layomia's request. |
DynamicallyAccessedMemberTypes.RecursiveProperties/Constructors
.DynamicallyAccessedMemberKinds.RecursiveProperties
linker#1087 (comment).Deserializing immutable collections is not linker safe - will address with #38593.