Skip to content

Exceptions from CSharpDeclareAsNullableCodeFixProvider #44338

@TessenR

Description

@TessenR

Version Used:

Microsoft Visual Studio Professional 2019 Preview
Version 16.6.0 Preview 6.0
VisualStudio.16.Preview/16.6.0-pre.6.0+30105.148
Microsoft .NET Framework
Version 4.8.03752

Steps to Reproduce:

Place caret at null in the following code:

using System.Threading;

#nullable enable
class C
{
  void M1()
  {
    string _path = "";
    var path = Interlocked.Exchange(ref _path, null);
  }
}

Expected Behavior:
No exceptions

Actual Behavior:
image

System.IndexOutOfRangeException : Index was outside the bounds of the array.
   at Microsoft.CodeAnalysis.CSharp.CodeFixes.DeclareAsNullable.CSharpDeclareAsNullableCodeFixProvider.<TryGetDeclarationTypeToFix>g__TryGetParameterTypeSyntax|13_2(IParameterSymbol parameterSymbol)
   at Microsoft.CodeAnalysis.CSharp.CodeFixes.DeclareAsNullable.CSharpDeclareAsNullableCodeFixProvider.TryGetDeclarationTypeToFix(SemanticModel model,SyntaxNode node)
   at async Microsoft.CodeAnalysis.CSharp.CodeFixes.DeclareAsNullable.CSharpDeclareAsNullableCodeFixProvider.RegisterCodeFixesAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeFixes.CodeFixService.GetCodeFixesAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEBugIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringsResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions