Add `IMethodSymbol Deconstruct` to `IDeconstructionAssignmentOperation`
Background and Motivation
We have it like that right now:
public interface IDeconstructionAssignmentOperation : IAssignmentOperation
{
}
Proposed API
Would be nice for the compiler to do the heavy lifting and get the symbol to the proper method being called:
public interface IDeconstructionAssignmentOperation : IAssignmentOperation
{
+ IMethodSymbol Deconstruct;
}
PS: I simplified the issue scheme because it's far too simple of a change. What do you think?
PS: I simplified the issue scheme because it's far too simple of a change. What do you think?
@B1Z0N could you please fill out the entire template? Every change needs a justification; what is the scenario you're trying to use this in? What do you have to write today? How would this API change that?
Championing this. IDE needs this in analyzers like the "remove unused members" analyzer to know that the .Deconstruct method is actually used.
That said, it seems like we need to expose something more like DeconstructInfo which ahs the target, as well as deep nested info about conversions
Ok. I ahve updated the proposal. It adds a CommonDeconstructionInfo which maps to the C# specific DeconstructionInfo: https://github.com/dotnet/roslyn/blob/main/src/Compilers/CSharp/Portable/Compilation/DeconstructionInfo.cs. Just like the C# version, it exposes the 'Method' and 'Conversion' (though as a CommonConversion as we're in the common layer), as well as nested infos.
@CyrusNajmabadi we have extension methods for getting C# and VB specific conversions off an IConversionOperation; do you want to propose similar extensions for getting language-specific deconstruction info?
That makes a lot of sense @333fred . will update.
API Review
- Could we just have the extension method?
- Wouldn't work well. The pain point is that we have to do language-specifics
- Names look good and match up with existing public API for DeconstructionInfo.
- If we need to, we'll look at calculating for CommonDeconstructionInfo lazily to avoid expensive work.
Conclusion: Approved