Skip to content

IntroduceVariableCodeRefactoringProviderSystem.ArgumentOutOfRangeException : 'end' must not be less than 'start' #27949

@davkean

Description

@davkean

Had the following invalid code while refactoring:

        public static ImageMoniker ApplicationPrivate = return new ImageMoniker { Guid = s_manifestGuid, Id = 0 };
        public static ImageMoniker ApplicationWarning = return new ImageMoniker { Guid = s_manifestGuid, Id = 1 };

        public static ImageMoniker CodeInformationPrivate = return new ImageMoniker { Guid = s_manifestGuid, Id = 2 };

        public static ImageMoniker CodeInformationWarning = return new ImageMoniker { Guid = s_manifestGuid, Id = 3 };

        public static ImageMoniker Component = return new ImageMoniker { Guid = s_manifestGuid, Id = 4 };

        public static ImageMoniker ComponentPrivate = return new ImageMoniker { Guid = s_manifestGuid, Id = 5 };

        public static ImageMoniker ComponentWarning = return new ImageMoniker { Guid = s_manifestGuid, Id = 6 };
        public static ImageMoniker ErrorSmall = return new ImageMoniker { Guid = s_manifestGuid, Id = 7 };
System.ArgumentOutOfRangeException : 'end' must not be less than 'start'
Parameter name: end
   at Microsoft.CodeAnalysis.Text.TextSpan.FromBounds(Int32 start,Int32 end)
   at Microsoft.CodeAnalysis.IntroduceVariable.AbstractIntroduceVariableService`6.State.GetExpressionUnderSpan(SyntaxTree tree,TextSpan textSpan,CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.IntroduceVariable.AbstractIntroduceVariableService`6.State.TryInitialize(TextSpan textSpan,CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.IntroduceVariable.AbstractIntroduceVariableService`6.State.Generate(TService service,SemanticDocument document,TextSpan textSpan,CancellationToken cancellationToken)
   at async Microsoft.CodeAnalysis.IntroduceVariable.AbstractIntroduceVariableService`6.IntroduceVariableAsync[TService,TExpressionSyntax,TTypeSyntax,TTypeDeclarationSyntax,TQueryExpressionSyntax,TNameSyntax](<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeRefactorings.IntroduceVariable.IntroduceVariableCodeRefactoringProvider.ComputeRefactoringsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringService.GetRefactoringFromProviderAsync(<Unknown Parameters>)
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

Metadata

Metadata

Assignees

Labels

Area-IDEBugDeveloper CommunityThe issue was originally reported on https://developercommunity.visualstudio.comResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions