codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

Start Position must lie inside rance

Open TechnVision opened this issue 2 years ago • 1 comments

Environment

  • Visual Studio version: 2022 Community
  • CodeMaid version: 12.0
  • Code language: C#

Here is the stack trance that I get in output window, but not so sure why this happens, my project builds and works fine but some sort of error is thrown here.

[CodeMaid Handled Exception 12:00:04 AM] CodeMaid Cleanup for 'FrmCreateNewCompany.cs' was stopped: System.ArgumentException: startingPosition (132497) must lie inside searchRange ([0..132496)) Parameter name: startingPosition at Microsoft.VisualStudio.Text.Find.Implementation.BaseFinderForSnapshot.AdjustSearchRange(Int32 startingPosition, Span searchRange) at Microsoft.VisualStudio.Text.Find.Implementation.BaseFinderForSnapshot.TryFind(Int32 startingPosition, Span searchRange, Span& result) at Microsoft.VisualStudio.Text.Find.Implementation.BaseFinderForSnapshot.TryFind(Int32 startingPosition, Span& result) at SteveCadwallader.CodeMaid.Helpers.TextDocumentHelper.<>c__DisplayClass4_0.<TryFindNextMatch>b__0() in C:\projects\codemaid\CodeMaidShared\Helpers\TextDocumentHelper.cs:line 130 at SteveCadwallader.CodeMaid.Helpers.TextDocumentHelper.<>c__DisplayClass20_0.<<RunOnUIThread>b__0>d.MoveNext() in C:\projects\codemaid\CodeMaidShared\Helpers\TextDocumentHelper.cs:line 448 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread() at SteveCadwallader.CodeMaid.Helpers.TextDocumentHelper.RunOnUIThread(Action action) in C:\projects\codemaid\CodeMaidShared\Helpers\TextDocumentHelper.cs:line 450 at SteveCadwallader.CodeMaid.Helpers.TextDocumentHelper.TryFindNextMatch(EditPoint startPoint, EditPoint& endPoint, String patternString) in C:\projects\codemaid\CodeMaidShared\Helpers\TextDocumentHelper.cs:line 144 at SteveCadwallader.CodeMaid.Logic.Cleaning.UpdateLogic.UpdateEndRegionDirectives(TextDocument textDocument) in C:\projects\codemaid\CodeMaidShared\Logic\Cleaning\UpdateLogic.cs:line 72 at SteveCadwallader.CodeMaid.Logic.Cleaning.CodeCleanupManager.RunCodeCleanupCSharp(Document document) in C:\projects\codemaid\CodeMaidShared\Logic\Cleaning\CodeCleanupManager.cs:line 335 at SteveCadwallader.CodeMaid.Logic.Cleaning.CodeCleanupManager.<>c__DisplayClass19_0.<Cleanup>b__0() in C:\projects\codemaid\CodeMaidShared\Logic\Cleaning\CodeCleanupManager.cs:line 170 at SteveCadwallader.CodeMaid.Helpers.UndoTransactionHelper.Run(Action tryAction, Action`1 catchAction) in C:\projects\codemaid\CodeMaidShared\Helpers\UndoTransactionHelper.cs:line 55

TechnVision avatar Dec 22 '23 18:12 TechnVision

I have exactly the same issue. From my testing, it happens for certain when the entire file is surrounded with #if/#endif. Not sure about other preprocessor macros, though.

asdfchlwnsgy1236 avatar Apr 08 '24 03:04 asdfchlwnsgy1236