-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Resolve ILLink warnings in System.Linq.Expressions (Round 3) #47938
Resolve ILLink warnings in System.Linq.Expressions (Round 3) #47938
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/MemberExpression.cs
Outdated
Show resolved
Hide resolved
Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @tannergooding, @sbomer Issue DetailsContributes to #45623
|
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/AssemblyGen.cs
Show resolved
Hide resolved
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/MemberExpression.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/MethodCallExpression.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/MemberExpression.cs
Outdated
Show resolved
Hide resolved
@@ -150,6 +150,7 @@ public static MemberExpression Field(Expression? expression, FieldInfo field) | |||
/// <param name="expression">The containing object of the field. This can be null for static fields.</param> | |||
/// <param name="fieldName">The field to be accessed.</param> | |||
/// <returns>The created <see cref="MemberExpression"/>.</returns> | |||
[RequiresUnreferencedCode(ExpressionRequiresUnreferencedCode)] |
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 haven't realizes that linker has intrinsic handling for some of the Expression.
static creation methods. For example field (and property) are here: https://github.com/mono/linker/blob/319ed02ed9a25ec3800f723ff72a1eb92ef050c7/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs#L722
I don't think there's anything to be done here - linker will not report the warning if the intrinsic handling kicks in - we should leave the method annotated like this for sure.
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/MemberExpression.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/AssemblyGen.cs
Show resolved
Hide resolved
src/libraries/System.Linq.Expressions/src/System/Dynamic/DynamicObject.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/MemberExpression.cs
Outdated
Show resolved
Hide resolved
@@ -139,5 +139,29 @@ | |||
<property name="Scope">member</property> | |||
<property name="Target">M:Microsoft.CSharp.RuntimeBinder.SymbolTable.AddNamesInInheritanceHierarchy(System.String,System.Collections.Generic.List{System.Type})</property> | |||
</attribute> | |||
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute"> |
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.
How come these are necessary now? This is in Microsoft.CSharp
which should not be affected by this PR, right?
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.
which should not be affected by this PR
This isn't true. Microsoft.CSharp
references System.Linq.Expressions:
<Reference Include="System.Linq.Expressions" /> |
Since I'm adding annotations to System.Linq.Expressions (specifically RequiresUnreferencedCode attributes), it is causing more warnings in the downstream assembly. For example, this is now unsafe:
Lines 24 to 27 in 1d9e50c
return Expression.Property( | |
Helpers.Convert(base.Marshal(parameter), typeof(CurrencyWrapper)), | |
nameof(CurrencyWrapper.WrappedObject) | |
); |
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.
Thanks - didn't realize that there are dependencies...
@@ -1162,6 +1163,7 @@ public static MethodCallExpression Call(Expression instance, string methodName, | |||
/// <exception cref="ArgumentNullException"> | |||
/// <paramref name="type"/> or <paramref name="methodName"/> is null.</exception> | |||
/// <exception cref="InvalidOperationException">No method whose name is <paramref name="methodName"/>, whose type parameters match <paramref name="typeArguments"/>, and whose parameter types match <paramref name="arguments"/> is found in <paramref name="type"/> or its base types.-or-More than one method whose name is <paramref name="methodName"/>, whose type parameters match <paramref name="typeArguments"/>, and whose parameter types match <paramref name="arguments"/> is found in <paramref name="type"/> or its base types.</exception> | |||
[RequiresUnreferencedCode(GenericMethodRequiresUnreferencedCode)] | |||
public static MethodCallExpression Call( |
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.
There's an intrinsic for Call in linker, so the annotations are not actually used by the linker (but they should remain for sure). Unfortunately there's a bug which will make all the generic method cases not warn: dotnet/linker#1819
Needs to be fixed,
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.
Looks good to me - not sure if there are some tests we should add, at least a little bit.
allConfigurations failure is #48075. |
Contributes to #45623