Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

[DAM analyzer] don't produce dataflow warnings for compiler-generated code #2587

Closed

Description

@sbomer

This issue tracks temporarily disabling dataflow warnings in the analyzer for compiler-generated code, until the linker better understands compiler-generated code.

Because the linker sees compiler-generated code for lambdas/iterators/async/local functions, it produces different dataflow warnings than those naturally produced by the analyzer. In particular, parameters and locals which are lifted to fields of state machines will show up as IL2077, whereas the linker will produce IL2066 for parameters.

Until the linker is fixed to produce the correct warnings for compiler-generated code, we would like the analyzer not to produce any warnings for these patterns. (This seems better than the alternative of producing slightly different warning codes for the same pattern, which would create usability issues - people would add annotations according to the analyzer warnings, but would get a completely different set when actually linking).

Activity

  1. tlakollo commented on Feb 5, 2022

    @tlakollo
    Contributor

    Related to #2583

  2. self-assigned this
    on Feb 10, 2022
  3. LakshanF commented on Feb 15, 2022

    @LakshanF
    Contributor

    We are planning to follow the following principles wrt analyzer warnings until the linker compiler generated work is done;

    1. Linker can generate additional warnings
    2. Analyzer should not produce any warnings that are different from the linker
  4. LakshanF commented on Feb 15, 2022

    @LakshanF
    Contributor

    The SuppressWarningsInCompilerGeneratedCode test has all the interesting test scenarios outlined in the "Handling of compiler generated code" document.

    The below table lists the test scenarios and the analyzer and linker behavior. As the table shows, rows 5 and 12, have analyzer generating different warnings (IL2067 to linker's IL2077). Currently local Functions and Lambdas are impacted by dotnet/runtime#84918 and do not produce the necessary warnings.

    <style> </style>
    Row Category Subcategory Notes Method Suppression Trimmer Analyzer
    1 SuppressInIteratorBody Direct Call RUC TestCallRUCMethod 2026 No Warning No Warning
    2 SuppressInIteratorBody Intrisics RUC TestReflectionAccessRUCMethod 2026 No Warning No Warning
    3 SuppressInIteratorBody Lambda RUC TestLdftnOnRUCMethod 2026 No Warning No Warning
    4 SuppressInIteratorBody DF - DAMT.NonPublic Type member annotated with RUC TestDynamicallyAccessedMethod 2026 No Warning No Warning
    5 SuppressInIteratorBody DF - DAMT.NonPublic Type is null TestMethodParameterWithRequirements 2077 No Warning 2067
    6 SuppressInIteratorBody DF - GenericParameter Method TestGenericMethodParameterRequirement 2091 No Warning No Warning
    7 SuppressInIteratorBody DF - GenericParameter Type TestGenericTypeParameterRequirement 2091 No Warning No Warning
    8 SuppressInAsyncBody Direct Call RUC TestCallRUCMethod 2026 No Warning No Warning
    9 SuppressInAsyncBody Intrisics RUC TestReflectionAccessRUCMethod 2026 No Warning No Warning
    10 SuppressInAsyncBody Lambda RUC TestLdftnOnRUCMethod 2026 No Warning No Warning
    11 SuppressInAsyncBody DF - DAMT.NonPublic Type member annotated with RUC TestDynamicallyAccessedMethod 2026 No Warning No Warning
    12 SuppressInAsyncBody DF - DAMT.NonPublic Type is null TestMethodParameterWithRequirements 2077 No Warning 2067
    13 SuppressInAsyncBody DF - GenericParameter Method TestGenericMethodParameterRequirement 2091 No Warning No Warning
    14 SuppressInAsyncBody DF - GenericParameter Type TestGenericTypeParameterRequirement 2091 No Warning No Warning
    15 SuppressInLocalFunction Direct Call RUC TestCallRUCMethod 2026 Warning in local Fn No Warning
    16 SuppressInLocalFunction Intrisics RUC TestReflectionAccessRUCMethod 2026 Warning in local Fn No Warning
    17 SuppressInLocalFunction Lambda RUC TestLdftnOnRUCMethod 2026 Warning in local Fn No Warning
    18 SuppressInLocalFunction DF - DAMT.NonPublic Type member annotated with RUC TestDynamicallyAccessedMethod 2026 Warning in local Fn No Warning
    19 SuppressInLocalFunction DF - DAMT.NonPublic Type is null TestMethodParameterWithRequirements 2077 Warning in local Fn No Warning
    20 SuppressInLocalFunction DF - GenericParameter Method TestGenericMethodParameterRequirement 2091 Warning in local Fn No Warning
    21 SuppressInLocalFunction DF - GenericParameter Type TestGenericTypeParameterRequirement 2091 Warning in local Fn No Warning
    22 SuppressInLocalFunction DF - GenericParameter Local Fn has DAMT on T TestGenericLocalFunction 2091 No Warning No Warning
    23 SuppressInLocalFunction DF - GenericParameter Local Fn has calls to DAMT methods TestGenericLocalFunctionInner 2087 Warning in local Fn No Warning
    24 SuppressInLocalFunction DF - GenericParameter Parent has correct DAMT annotation & local calls DAMT methods TestGenericLocalFunctionWithAnnotations None No Warning No Warning
    25 SuppressInLocalFunction DF - GenericParameter Parent & local has correct DAMT annotation & local calls DAMT methods TestGenericLocalFunctionWithAnnotationsAndClosure None No Warning No Warning
    26 SuppressInLocalFunction Lambda RUC - local fun is created as a lambda! TestCallRUCMethodInLtftnLocalFunction 2026 Warning in local Fn No Warning
    27 SuppressInLocalFunction DF - DAMT.NonPublic DF for a class where a method has a local fn that calls RUC DynamicallyAccessedLocalFunction.TestCallRUCMethodInDynamicallyAccessedLocalFunction 2026 Warning in local Fn No Warning
    28 SuppressInLocalFunction Direct Call RUC suppression on local fn TestSuppressionOnLocalFunction Local Fn - 2026 No Warning No Warning
    29 SuppressInLocalFunction Direct Call + DF RUC suppression on local fn TestSuppressionOnOuterAndLocalFunction Local Fn - 2026, Outer 2067 Warning in local Fn - 2067 No Warning
    30 SuppressInLambda Direct Call RUC suppressed on parent TestCallRUCMethod 2026 Warning on Parent No Warning
    31 SuppressInLambda Intrisics RUC suppressed on parent TestReflectionAccessRUCMethod 2026 Warning on Parent No Warning
    32 SuppressInLambda Lambda RUC suppressed on parent TestLdftnOnRUCMethod 2026 Warning on Parent No Warning
    33 SuppressInLambda DF - DAMT.NonPublic Type member annotated with RUC TestDynamicallyAccessedMethod 2026 Warning on Parent No Warning
    34 SuppressInLambda DF - DAMT.NonPublic Type is null TestMethodParameterWithRequirements 2077 Warning on Parent No Warning
    35 SuppressInLambda DF - GenericParameter Method TestGenericMethodParameterRequirement 2091 Warning on Parent No Warning
    36 SuppressInLambda DF - GenericParameter Type TestGenericTypeParameterRequirement 2091 Warning on Parent No Warning
    37 SuppressInComplex Direct Call to RUC in local fun Iterator is a local fn and both parent and local fn has suppression TestIteratorLocalFunctionInAsync Parent and Local Fn - 2026 No Warning No Warning
    38 SuppressInComplex Direct Call to RUC in local fun Iterator is a local fn and parent has suppression TestIteratorLocalFunctionInAsyncWithoutInner 2026 Warning in local Fn No Warning
    39 SuppressInComplex Iterator has a DF method with RUC Iterator has a DF method with RUC TestDynamicallyAccessedMethodViaGenericMethodParameterInIterator 2026 No Warning No Warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions