codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

Handled exception - Value does not fall within expected range.

Open sleepyspider1 opened this issue 7 years ago • 5 comments

Environment

  • Visual Studio version: Visual Studio 2015 Professional Update 3
  • CodeMaid version: 10.4.53
  • Code language: C++

Description

CodeMaid doesn't do anything for me with this error.

Steps to recreate

When I try to format the document, this error spits out but no formatting occurs.

Current behavior

[CodeMaid Handled Exception 03:07:18 PM] TryDefault caught an exception on 'System.Func1[System.Boolean]': System.ArgumentException: Value does not fall within the expected range. at EnvDTE80.CodeFunction2.get_FunctionKind() at SteveCadwallader.CodeMaid.Model.CodeItems.CodeItemMethod.<.ctor>b__6_4() at SteveCadwallader.CodeMaid.Model.CodeItems.BaseCodeItemElement.TryDefault[T](Func1 func) [CodeMaid Handled Exception 03:07:18 PM] TryDefault caught an exception on 'System.Func1[System.Boolean]': System.ArgumentException: Value does not fall within the expected range. at EnvDTE80.CodeFunction2.get_FunctionKind() at SteveCadwallader.CodeMaid.Model.CodeItems.CodeItemMethod.<.ctor>b__6_5() at SteveCadwallader.CodeMaid.Model.CodeItems.BaseCodeItemElement.TryDefault[T](Func1 func)

Expected behavior

Format document

sleepyspider1 avatar May 15 '18 20:05 sleepyspider1

Thanks for reporting the issue. The call stack looks like a very specific error with a method it cannot interpret. Can you provide a minimal file where this error occurs?

codecadwallader avatar May 19 '18 11:05 codecadwallader

I got a similar error:

[CodeMaid Handled Exception 10:02:09 AM] TryDefault caught an exception on 'System.Func`1[System.String]': System.ArgumentException: Value does not fall within the expected range.
   at EnvDTE80.CodeClass2.get_Namespace()
   at SteveCadwallader.CodeMaid.Model.CodeItems.CodeItemClass.<.ctor>b__0_4()
   at SteveCadwallader.CodeMaid.Model.CodeItems.BaseCodeItemElement.TryDefault[T](Func`1 func)
[CodeMaid Handled Exception 10:02:11 AM] TryDefault caught an exception on 'System.Func`1[System.String]': System.ArgumentException: Value does not fall within the expected range.
   at EnvDTE80.CodeClass2.get_Namespace()
   at SteveCadwallader.CodeMaid.Model.CodeItems.CodeItemClass.<.ctor>b__0_4()
   at SteveCadwallader.CodeMaid.Model.CodeItems.BaseCodeItemElement.TryDefault[T](Func`1 func)
[CodeMaid Handled Exception 10:02:12 AM] TryDefault caught an exception on 'System.Func`1[System.String]': System.ArgumentException: Value does not fall within the expected range.
   at EnvDTE.CodeEnum.get_Namespace()
   at SteveCadwallader.CodeMaid.Model.CodeItems.CodeItemEnum.<.ctor>b__0_3()
   at SteveCadwallader.CodeMaid.Model.CodeItems.BaseCodeItemElement.TryDefault[T](Func`1 func)
[CodeMaid Handled Exception 10:02:17 AM] TryDefault caught an exception on 'System.Func`1[System.String]': System.ArgumentException: Value does not fall within the expected range.
   at EnvDTE80.CodeClass2.get_Namespace()
   at SteveCadwallader.CodeMaid.Model.CodeItems.CodeItemClass.<.ctor>b__0_4()
   at SteveCadwallader.CodeMaid.Model.CodeItems.BaseCodeItemElement.TryDefault[T](Func`1 func)

aliha avatar Aug 23 '18 14:08 aliha

A code sample would be really helpful!

codecadwallader avatar Aug 25 '18 12:08 codecadwallader

I have the same issue in VS 2019 Here is the exception. I will attach the code file.

[CodeMaid Handled Exception 11:10:41 AM] CodeMaid Reorganize for 'GlobalModule.vb' was stopped: System.ArgumentException: Value does not fall within the expected range. at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.AbstractCodeModelService.LookupNode(SyntaxNodeKey nodeKey, SyntaxTree syntaxTree) at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.InternalElements.AbstractKeyedCodeElement.LookupNode() at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.InternalElements.AbstractCodeElement.GetStartPoint(vsCMPart part) at EnvDTE.CodeElement.GetStartPoint(vsCMPart Part) at SteveCadwallader.CodeMaid.Model.CodeItems.BaseCodeItemElement.RefreshCachedPositionAndName() in C:\projects\codemaid\CodeMaid\Model\CodeItems\BaseCodeItemElement.cs:line 69 at SteveCadwallader.CodeMaid.Logic.Reorganizing.CodeReorganizationManager.RepositionItemAboveBase(BaseCodeItem itemToMove, BaseCodeItem baseItem) in C:\projects\codemaid\CodeMaid\Logic\Reorganizing\CodeReorganizationManager.cs:line 264 at SteveCadwallader.CodeMaid.Logic.Reorganizing.CodeReorganizationManager.RecursivelyReorganize(IEnumerable1 codeItems, ICodeItemParent parent) in C:\projects\codemaid\CodeMaid\Logic\Reorganizing\CodeReorganizationManager.cs:line 381 at SteveCadwallader.CodeMaid.Logic.Reorganizing.CodeReorganizationManager.RecursivelyReorganize(IEnumerable1 codeItems, ICodeItemParent parent) in C:\projects\codemaid\CodeMaid\Logic\Reorganizing\CodeReorganizationManager.cs:line 374 at SteveCadwallader.CodeMaid.Logic.Reorganizing.CodeReorganizationManager.<>c__DisplayClass12_0.<Reorganize>b__0() in C:\projects\codemaid\CodeMaid\Logic\Reorganizing\CodeReorganizationManager.cs:line 124 at SteveCadwallader.CodeMaid.Helpers.UndoTransactionHelper.Run(Action tryAction, Action`1 catchAction) in C:\projects\codemaid\CodeMaid\Helpers\UndoTransactionHelper.cs:line 55 GlobalModule.vb.txt

cattman70 avatar Jul 13 '21 15:07 cattman70

Thanks for reporting the issue. I am able to reproduce it with a truncated version of the provided code sample:

Namespace Code
    Friend Structure RECT
        Public Bottom As Integer
    End Structure

    Public Module GlobalModule
        Public Const gCOMBOBOX_NOTHINGSELECTED As Integer = -1
    End Module
End Namespace

It looks like the code tree may not be properly parsing the module node as it works as expected if that is switched to a structure.

codecadwallader avatar Jul 18 '21 20:07 codecadwallader