You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0de0ba8
Browse filesBrowse the repository at this point in the historyBrowse files
Add dataflow support for deconstruction assignments (dotnet#131624)
Fixesdotnet#123767.
The ILLink Roslyn analyzer's dataflow visitor did not handle
`IDeconstructionAssignmentOperation`, so `RequiresUnreferencedCode` and
`DynamicallyAccessedMembers` diagnostics were silently skipped for
values flowing through deconstruction, including assignments and
deconstruction in `foreach`.
## Summary of changes
- Add dataflow support for tuple expressions, tuple-typed values,
instance and extension `Deconstruct` methods, nested deconstruction, and
user-defined conversions.
- Support local, field, property, parameter, discard, array-element,
explicit-indexer, implicit-indexer, and nested tuple targets.
- Preserve C# evaluation order by evaluating target locations before
source values and performing target writes only after all source values
and nested `Deconstruct` calls have been evaluated.
- Preserve flow-captured target receivers and index arguments so target
locations are evaluated once and retain the values selected before
source-side mutations.
- Correctly map receivers for classic extension methods and C# 14
extension-block `Deconstruct` methods.
- Treat outer or nested `[DoesNotReturn] Deconstruct` calls as
unreachable and suppress every target assignment on that path.
## Testing
Added regression coverage for deconstruction sources, targets,
evaluation ordering, flow captures, extension receivers, user-defined
conversions, and direct and nested `[DoesNotReturn]` methods. The
DataFlow suites pass across:
- `ILLink.RoslynAnalyzer.Tests`
- `Mono.Linker.Tests`
- `ILCompiler.Trimming.Tests`
- `ILTrim.Tests`
Two unsupported ILTrim scenarios are isolated as standalone expected
failures instead of excluding the shared deconstruction coverage:
- `DeconstructFieldTarget` exposes an existing ILTrim.Core gap in
static-field write dataflow.
- `DeconstructUserDefinedConversion` exposes an existing ILTrim.Core gap
in tracking a user-defined conversion operator's return value.
The Roslyn analyzer, linker, and NativeAOT tests retain coverage for
both cases. ILLink/ILTrim and NativeAOT also conservatively report the
expected warning after `[DoesNotReturn]` calls because the IL-based
tools do not treat that attribute as a reachability contract; those
expectations are scoped to the IL-based tools while the Roslyn analyzer
verifies the path is unreachable.
> [!NOTE]
> This content was created with assistance from AI.
---------
Co-authored-by: Copilot <[email protected]>
Copilot-Session: b4dc4554-6607-4109-ab22-56a5815b294d
0 commit comments