dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.05k stars 4.04k forks source link

Renaming variable typed `nint`/`nuint` fails when multitargeting #68234

Open 333fred opened 1 year ago

333fred commented 1 year ago

Version Used: 17.6

Steps to Reproduce:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;net7.0</TargetFrameworks>
  </PropertyGroup>

</Project>
public class Class1
{
    public void M(nint foo) { }
}
  1. Create a project with the above files.
  2. Set the TFM to net7.0 in the editor.
  3. Rename foo.

Expected Behavior:

Parameter is renamed

Actual Behavior:

System.InvalidOperationException : Unexpected false - line 20
   at Roslyn.Utilities.Contract.Fail(String message,Int32 lineNumber)
   at Roslyn.Utilities.Contract.ThrowIfFalse(Boolean condition,Int32 lineNumber)
   at async Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.AbstractEditorInlineRenameService.InlineRenameLocationSet.GetReplacementsAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.<>c__DisplayClass76_0.<UpdateConflictResolutionTask>b__0(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.CommitCoreAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.CommitWorkerAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
   at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
   at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.InlineRenameSession.CommitWorker(Boolean previewChanges)
   at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.RenameCommandHandler.Commit(InlineRenameSession activeSession,ITextView textView)
333fred commented 1 year ago

Note: this was customer-reported, I just filed it on their behalf.