Skip to content
Prev Previous commit
Next Next commit
Respond to PR comments
  • Loading branch information
agocke authored and github-actions committed Aug 15, 2023
commit 119c7b54286d41399d499abfe3cf9fd217a43a78
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,13 @@ protected Expression(System.Linq.Expressions.ExpressionType nodeType, System.Typ
public static System.Linq.Expressions.NewExpression New(System.Reflection.ConstructorInfo constructor, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression>? arguments, params System.Reflection.MemberInfo[]? members) { throw null; }
public static System.Linq.Expressions.NewExpression New(System.Reflection.ConstructorInfo constructor, params System.Linq.Expressions.Expression[]? arguments) { throw null; }
public static System.Linq.Expressions.NewExpression New([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.NonPublicConstructors | System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type type) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")]
public static System.Linq.Expressions.NewArrayExpression NewArrayBounds(System.Type type, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> bounds) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")]
public static System.Linq.Expressions.NewArrayExpression NewArrayBounds(System.Type type, params System.Linq.Expressions.Expression[] bounds) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")]
public static System.Linq.Expressions.NewArrayExpression NewArrayInit(System.Type type, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> initializers) { throw null; }
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")]
public static System.Linq.Expressions.NewArrayExpression NewArrayInit(System.Type type, params System.Linq.Expressions.Expression[] initializers) { throw null; }
public static System.Linq.Expressions.UnaryExpression Not(System.Linq.Expressions.Expression expression) { throw null; }
public static System.Linq.Expressions.UnaryExpression Not(System.Linq.Expressions.Expression expression, System.Reflection.MethodInfo? method) { throw null; }
Expand Down Expand Up @@ -1028,6 +1032,7 @@ internal MethodCallExpression() { }
System.Linq.Expressions.Expression System.Linq.Expressions.IArgumentProvider.GetArgument(int index) { throw null; }
public System.Linq.Expressions.MethodCallExpression Update(System.Linq.Expressions.Expression? @object, System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression>? arguments) { throw null; }
}
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Creating arrays at runtime requires dynamic code generation.")]
public partial class NewArrayExpression : System.Linq.Expressions.Expression
{
internal NewArrayExpression() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,84 +133,12 @@
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Linq.Expressions.Expression.NewArrayBounds(System.Type,System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression}):[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Linq.Expressions.Expression.NewArrayBounds(System.Type,System.Linq.Expressions.Expression[]):[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Linq.Expressions.Expression.NewArrayInit(System.Type,System.Collections.Generic.IEnumerable{System.Linq.Expressions.Expression}):[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Linq.Expressions.Expression.NewArrayInit(System.Type,System.Linq.Expressions.Expression[]):[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Linq.Expressions.Expression`1.Compile:[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Linq.Expressions.Expression`1.Compile(System.Boolean):[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Linq.Expressions.Expression`1.Compile(System.Runtime.CompilerServices.DebugInfoGenerator):[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Linq.Expressions.LambdaExpression.Compile:[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Linq.Expressions.LambdaExpression.Compile(System.Boolean):[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Linq.Expressions.LambdaExpression.Compile(System.Runtime.CompilerServices.DebugInfoGenerator):[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Runtime.CompilerServices.CallSite.Create(System.Type,System.Runtime.CompilerServices.CallSiteBinder):[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>M:System.Runtime.CompilerServices.CallSite`1.Create(System.Runtime.CompilerServices.CallSiteBinder):[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0016</DiagnosticId>
<Target>T:System.Linq.Expressions.NewArrayExpression:[T:System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute]</Target>
<Left>ref/net8.0/System.Linq.Expressions.dll</Left>
<Right>lib/net8.0/System.Linq.Expressions.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0020</DiagnosticId>
<Target>M:System.Linq.Expressions.DynamicExpressionVisitor.#ctor</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract partial class Expression
internal const string CallSiteRequiresDynamicCode = "Creating a call site may require dynamic code generation.";
internal const string LambdaCompilerRequiresDynamicCode = "Compiling a lambda expression requires dynamic code generation.";
internal const string StrongBoxRequiresDynamicCode = "Creating a StrongBox requires dynamic code generation.";
internal const string NewArrayRequiresDynamicCode = "Creating arrays at runtime requires dynamic code generation. This warning can be suppressed if there are no new array nodes in the expression tree.";
internal const string NewArrayRequiresDynamicCode = "Creating arrays at runtime requires dynamic code generation.";

private static readonly CacheDict<Type, MethodInfo> s_lambdaDelegateCache = new CacheDict<Type, MethodInfo>(40);
private static volatile CacheDict<Type, Func<Expression, string?, bool, ReadOnlyCollection<ParameterExpression>, LambdaExpression>>? s_lambdaFactories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ public InterpretedFrameInfo(string? methodName, DebugInfo? info)
public override string? ToString() => _debugInfo != null ? _methodName + ": " + _debugInfo : _methodName;
}

[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
internal sealed class LightCompiler
{
private readonly InstructionList _instructions;
Expand Down Expand Up @@ -2510,8 +2509,12 @@ private void CompileMember(Expression? from, MemberInfo member, bool forBinding)
}
}

[UnconditionalSuppressMessage("DynamicDependency", "IL3050",
Justification = "NewArrayExpression has RequiresDynamicCode, so the only way to get here is by already "
+ "seeing a warning.")]
private void CompileNewArrayExpression(Expression expr)
{
Debug.Assert(typeof(NewArrayExpression).GetCustomAttribute<RequiresDynamicCodeAttribute>() is not null);
var node = (NewArrayExpression)expr;

foreach (Expression arg in node.Expressions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ internal static MethodInfo GetCompileMethod(Type lambdaExpressionType)
/// Produces a delegate that represents the lambda expression.
/// </summary>
/// <returns>A delegate containing the compiled version of the lambda.</returns>
[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
public Delegate Compile()
{
if (CanCompileToIL)
Expand All @@ -156,7 +155,6 @@ public Delegate Compile()
/// </summary>
/// <param name="preferInterpretation">A <see cref="bool"/> that indicates if the expression should be compiled to an interpreted form, if available.</param>
/// <returns>A delegate containing the compiled version of the lambda.</returns>
[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
public Delegate Compile(bool preferInterpretation)
{
if (CanInterpret && preferInterpretation)
Expand Down Expand Up @@ -190,7 +188,6 @@ public void CompileToMethod(System.Reflection.Emit.MethodBuilder method)
/// </summary>
/// <param name="debugInfoGenerator">Debugging information generator used by the compiler to mark sequence points and annotate local variables.</param>
/// <returns>A delegate containing the compiled version of the lambda.</returns>
[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
public Delegate Compile(DebugInfoGenerator debugInfoGenerator)
{
return Compile();
Expand Down Expand Up @@ -220,7 +217,6 @@ internal Expression(Expression body)
/// Produces a delegate that represents the lambda expression.
/// </summary>
/// <returns>A delegate containing the compiled version of the lambda.</returns>
[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
public new TDelegate Compile()
{
if (CanCompileToIL)
Expand All @@ -242,7 +238,6 @@ internal Expression(Expression body)
/// </summary>
/// <param name="preferInterpretation">A <see cref="bool"/> that indicates if the expression should be compiled to an interpreted form, if available.</param>
/// <returns>A delegate containing the compiled version of the lambda.</returns>
[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
public new TDelegate Compile(bool preferInterpretation)
{
if (CanInterpret && preferInterpretation)
Expand Down Expand Up @@ -337,7 +332,6 @@ internal static Expression<TDelegate> Create(Expression body, string? name, bool
/// </summary>
/// <param name="debugInfoGenerator">Debugging information generator used by the compiler to mark sequence points and annotate local variables.</param>
/// <returns>A delegate containing the compiled version of the lambda.</returns>
[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
public new TDelegate Compile(DebugInfoGenerator debugInfoGenerator)
{
return Compile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static NewArrayExpression NewArrayBounds(Type type, params Expression[] b
/// <param name="type">A <see cref="System.Type"/> that represents the element type of the array.</param>
/// <param name="bounds">An <see cref="IEnumerable{T}"/> that contains <see cref="Expression"/> objects to use to populate the <see cref="NewArrayExpression.Expressions"/> collection.</param>
/// <returns>A <see cref="NewArrayExpression"/> that has the <see cref="NodeType"/> property equal to <see cref="ExpressionType.NewArrayBounds"/> and the <see cref="NewArrayExpression.Expressions"/> property set to the specified value.</returns>
[RequiresDynamicCode(Expression.CallSiteRequiresDynamicCode)]
[RequiresDynamicCode(Expression.NewArrayRequiresDynamicCode)]
public static NewArrayExpression NewArrayBounds(Type type, IEnumerable<Expression> bounds)
{
ArgumentNullException.ThrowIfNull(type);
Expand Down