-
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
Creating new TypeName without reparsing + usage in NRBF #103713
Conversation
…ames is set to false, parse assembly name once and just reuse it
Note regarding the
|
1 similar comment
Note regarding the
|
src/libraries/System.Reflection.Metadata/ref/System.Reflection.Metadata.cs
Outdated
Show resolved
Hide resolved
The Line 431 in 9e57de2
Should |
Sounds good to me. I assume that you are thinking about requiring |
|
I do not think that regular reflection APIs allow this. Why would we want to allow it? If users want to change generic args of constructed generic type, they should get the generic type definition first on their side. |
# Conflicts: # src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/SerializationRecord.cs
…SimpleNames: - all TypeName instances remain always valid and escaped - it's impossible to detect all sequences that are escaped
src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/Utils/TypeNameHelpers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/Utils/TypeNameHelpers.cs
Show resolved
Hide resolved
src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/Utils/TypeNameHelpers.cs
Outdated
Show resolved
Hide resolved
/// <param name="assemblyName">Assembly name.</param> | ||
/// <returns>Created simple name.</returns> | ||
/// <exception cref="InvalidOperationException">The current type name is not simple.</exception> | ||
public TypeName MakeSimpleTypeName(AssemblyNameInfo? assemblyName) |
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.
If you believe that this name is wrong
Yes, I think that the method name is not right. The conceptual behavior of this method does not match any other Make...
instance method in the BCL. The established BCL pattern for methods that change properties of immutable types is With...
instance or extension method.
We consider BCL prior art when naming new APIs to maintain consistency. (MakeSimpleTypeName
name would be ok if there was no BCL prior art.)
it does not suggest anything that it's going to work only for simple names.
I do not think that it is a problem. It is common for APIs to have additional limitations for how they can be used that are not captured in the API name. For example, WithDegreeOfParallelism
can be used at most once per query, but this limitation is not captured in the API name.
The BF scenario is important to me and I am not convinced that I don't need it.
Do you agree that it is just a minor optimization, and that this exact API is not required to make the Nrbf-reader secure?
For Nrbf-reader security, you should only need to avoid non-linear amount of work that can be achieved via more general-purpose set of APIs.
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeName.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/Utils/TypeNameHelpers.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeName.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeName.cs
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeName.cs
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeName.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/TypeName.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.
System.Reflection.Metadata part LGTM modulo comments. Thank you!
src/libraries/System.Formats.Nrbf/src/System/Formats/Nrbf/Utils/TypeNameHelpers.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.
Style violations must be corrected.
Co-authored-by: Jeremy Barton <jbarton@microsoft.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com>
…n the future and should not be enforced by the parser
The suggestion has been applied and the feedback was addressed.
@jkotas I've tried to implement the APIs we have discussed in #102263 and so far it looks good.
I need to spend more time testing
MakeGenericTypeName
and thinking about all edge cases.contributes to #102263
fixes #106022