New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeMaid Handled Exception - IsExternal and GetParentProjectItem #255

Closed
montgomerybc opened this Issue Apr 6, 2016 · 10 comments

Comments

Projects
None yet
2 participants
@montgomerybc

montgomerybc commented Apr 6, 2016

Environment

  • Visual Studio version: Microsoft Visual Studio Enterprise 2015 Version 14.0.25123.00 Update 2
  • CodeMaid version: 10.0.72
  • Code language: Javascript

Description

After I switch to a window with a simple javascript controller I get repeated exceptions until I switch to a different window. Visual Studio often blocks and may not shut down properly

Steps to recreate

  1. create file bookController.js with the following (JSFiddle here):
    (function (bookController) { bookController.init = function (app) { app.get("/foo", function (req, res) { res.render("index", { firstname: "John", lastname: "Smith", title: "blah" }); }) } })(module.exports);
  2. open file in Visual Studio

Current behavior

[CodeMaid Diagnostic 10:53:48 PM] WindowEventListener.OnWindowChange raised for '...\bookController.js'

The following 2 exceptions repeat, typically many times per second:

[CodeMaid Handled Exception 10:53:49 PM] Unable to determine if ProjectItem is external: System.InvalidOperationException: Operation is not valid due to the current state of the object.
at Microsoft.VisualStudioTools.Project.Automation.OAProjectItem.get_Collection()
at SteveCadwallader.CodeMaid.Helpers.ProjectItemExtensions.IsExternal(ProjectItem projectItem)
[CodeMaid Handled Exception 10:53:49 PM] Unable to retrieve parent ProjectItem: System.InvalidOperationException: Operation is not valid due to the current state of the object.
at Microsoft.VisualStudioTools.Project.Automation.OAProjectItem.get_Collection()
at SteveCadwallader.CodeMaid.Helpers.ProjectItemExtensions.GetParentProjectItem(ProjectItem projectItem)

If I switch to another window, the exceptions stop

Expected behavior

No exceptions

@codecadwallader codecadwallader added the bug label Apr 6, 2016

@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Apr 6, 2016

Thanks for reporting the issue. A couple questions:

  1. Did you see this issue before installing the latest VS2015 Update 2 RC?
  2. Are you opening that file by itself (no Visual Studio solution), or is it a part of a solution (e.g. MVC)?
@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Apr 6, 2016

I haven't reproduced the issue yet (using VS2015 Update 1), but I did see an unrelated issue when testing the no-solution scenario and created #256

@montgomerybc

This comment has been minimized.

montgomerybc commented Apr 6, 2016

  1. I did see this issue (or one that looked very much like it with
    repeating exceptions) but I didn't do any investigation. I'm not sure what
    sort of file it was.
  2. It was part of a solution. If it matters is was a "Basic Node.js
    Express 4 application" IIRC

I will try to open the file directly, outside the solution, likely this
evening.

Thank you.

-Dave

On 6 April 2016 at 05:07, Steve Cadwallader notifications@github.com
wrote:

I haven't reproduced the issue yet (using VS2015 Update 1), but I did see
an unrelated issue when testing the no-solution scenario and created #256
#256


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#255 (comment)

@codecadwallader codecadwallader added this to the v10.1 milestone Apr 7, 2016

@codecadwallader codecadwallader self-assigned this Apr 7, 2016

codecadwallader added a commit that referenced this issue Apr 7, 2016

@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Apr 7, 2016

Thanks for the extra details, especially that you were using a Node.JS/Express solution. I have now reproduced the repeated warning messages, but not the hang.

NTVS (Node.JS Tools for Visual Studio) does not implement part of the VS API the same as other languages.. which results in the error messages being created. See #107 and #175 for some background on the issue we encountered when originally adding support for NTVS. The workaround is that these methods all have fallback behavior and provide the warning.

Since these are "known" exceptions in some scenarios, I have demoted them to only appear when Diagnostics Mode (within CodeMaid->Options) is enabled.

Since I didn't reproduce the hang, I don't know if this will address the issue you are seeing. Would you mind testing the latest CI build at http://vsixgallery.com/extension/4c82e17d-927e-42d2-8460-b473ac7df316/ (10.0.76 or higher) to see if that changes the behavior at all?

If it doesn't address the issue (which wouldn't surprise me), then this would be a similar issue to #227 where the repeated checking of command availability is causing issues.. and I might consider keeping the commands permanently enabled vs. dynamically enabling/disabling them. That would bypass some state checks until on demand vs. on API demand which is triggered pretty frequently.

@montgomerybc

This comment has been minimized.

montgomerybc commented Apr 7, 2016

I've updated to the CI build. No change in behaviour.

There are no exceptions if I don't have a solution loaded. I have repeated
the test several times and in all cases: no solution = no exceptions.
solution = exceptions.

In case it's helpful, I grabbed the diagnostic log when I set focus into
the misbehaving code and back out:
** With no solution loaded
[CodeMaid Diagnostic 09:33:07 PM] WindowEventListener.OnWindowChange raised
for 'D:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:07 PM]
CodeModelManager.RetrieveAllCodeItemsAsync for
'D:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:07 PM] CodeModelCache.GetCodeModel for
'D:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:07 PM] --retrieved from cache (not stale).

** With solution loaded
[CodeMaid Diagnostic 09:33:44 PM] WindowEventListener.OnWindowChange raised
for 'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:44 PM]
CodeModelManager.RetrieveAllCodeItemsAsync for
'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:44 PM] CodeModelCache.GetCodeModel for
'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:44 PM] CodeModel.IsStale changing to 'True' for
'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:44 PM] --added to cache (stale).
[CodeMaid Diagnostic 09:33:44 PM] CodeModelManager.BuildCodeItems started
for 'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:44 PM] CodeModel.IsBuilding changing to 'True'
for 'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:44 PM] CodeModel.IsStale changing to 'False' for
'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:44 PM] CodeModel.IsBuilding changing to 'False'
for 'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:44 PM] CodeModelManager.BuildCodeItems completed
for 'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:44 PM]
CodeModelManager.LoadLazyInitializedValues for
'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:44 PM] CodeModelManager.CodeModelBuilt raised
for 'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\public\js\bookViewModel.js'
[CodeMaid Diagnostic 09:33:44 PM] Unable to determine if ProjectItem is
external: System.InvalidOperationException: Operation is not valid due to
the current state of the object.
at
Microsoft.VisualStudioTools.Project.Automation.OAProjectItem.get_Collection()
at
SteveCadwallader.CodeMaid.Helpers.ProjectItemExtensions.IsExternal(ProjectItem
projectItem)
[CodeMaid Diagnostic 09:33:44 PM] Unable to retrieve parent ProjectItem:
System.InvalidOperationException: Operation is not valid due to the current
state of the object.
at
Microsoft.VisualStudioTools.Project.Automation.OAProjectItem.get_Collection()
at
SteveCadwallader.CodeMaid.Helpers.ProjectItemExtensions.GetParentProjectItem(ProjectItem
projectItem)
[CodeMaid Diagnostic 09:33:45 PM] Unable to determine if ProjectItem is
external: System.InvalidOperationException: Operation is not valid due to
the current state of the object.
at
Microsoft.VisualStudioTools.Project.Automation.OAProjectItem.get_Collection()
at
SteveCadwallader.CodeMaid.Helpers.ProjectItemExtensions.IsExternal(ProjectItem
projectItem)
[CodeMaid Diagnostic 09:33:45 PM] Unable to retrieve parent ProjectItem:
System.InvalidOperationException: Operation is not valid due to the current
state of the object.
at
Microsoft.VisualStudioTools.Project.Automation.OAProjectItem.get_Collection()
at
SteveCadwallader.CodeMaid.Helpers.ProjectItemExtensions.GetParentProjectItem(ProjectItem
projectItem)
[CodeMaid Diagnostic 09:33:46 PM] Unable to determine if ProjectItem is
external: System.InvalidOperationException: Operation is not valid due to
the current state of the object.
at
Microsoft.VisualStudioTools.Project.Automation.OAProjectItem.get_Collection()
at
SteveCadwallader.CodeMaid.Helpers.ProjectItemExtensions.IsExternal(ProjectItem
projectItem)
[CodeMaid Diagnostic 09:33:46 PM] Unable to retrieve parent ProjectItem:
System.InvalidOperationException: Operation is not valid due to the current
state of the object.
at
Microsoft.VisualStudioTools.Project.Automation.OAProjectItem.get_Collection()
at
SteveCadwallader.CodeMaid.Helpers.ProjectItemExtensions.GetParentProjectItem(ProjectItem
projectItem)
[CodeMaid Diagnostic 09:33:46 PM] WindowEventListener.OnWindowChange raised
for 'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\app.js'
[CodeMaid Diagnostic 09:33:46 PM]
CodeModelManager.RetrieveAllCodeItemsAsync for
'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\app.js'
[CodeMaid Diagnostic 09:33:46 PM] CodeModelCache.GetCodeModel for
'd:\Users\David\Documents\Visual Studio
2015\Projects\ExpressApp2\ExpressApp2\app.js'
[CodeMaid Diagnostic 09:33:46 PM] --retrieved from cache (not stale).

Also, here is the full info of what I have installed. Please note that I
have disabled everything that can be disabled with the exception of
CodeMaid. No change in behaviour.

Microsoft Visual Studio Enterprise 2015
Version 14.0.25123.00 Update 2
Microsoft .NET Framework
Version 4.6.01038

Installed Version: Enterprise

Architecture and Modeling Tools 00322-90200-03631-AA416
Microsoft Architecture and Modeling Tools

UML® and Unified Modeling Language™ are trademarks or registered trademarks
of the Object Management Group, Inc. in the United States and other
countries.

Visual Basic 2015 00322-90200-03631-AA416
Microsoft Visual Basic 2015

Visual C# 2015 00322-90200-03631-AA416
Microsoft Visual C# 2015

Visual C++ 2015 00322-90200-03631-AA416
Microsoft Visual C++ 2015

Application Insights Tools for Visual Studio Package 5.2.60328.3
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015 (RC1 Update 1) 14.1.20203.0
ASP.NET and Web Tools 2015 (RC1 Update 1)

ASP.NET Web Frameworks and Tools 2012.2 4.1.41102.0
For additional information, visit
http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013 5.2.40314.0
For additional information, visit http://www.asp.net/

Azure App Service Tools v2.9 14.0.20316.0
Azure App Service Tools v2.9

Azure Data Lake Node 1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio 2.0.6000.0
Microsoft Azure Data Lake Tools for Visual Studio

CodeMaid 10.0.76
CodeMaid is an open source Visual Studio extension to cleanup and simplify
our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS,
LESS, SCSS, JavaScript and TypeScript coding.

Common Azure Tools 1.7
Provides common services for use by Azure Mobile Services and Microsoft
Azure Tools.

DataFactoryProject 1.0
Microsoft Data Factory Package

GitHub.VisualStudio 1.0
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service 2.0
JavaScript Language Service

JavaScript Project System 2.0
JavaScript Project System

Microsoft Azure Data Factory Node Node 1.0
Azure Data Factory extension for Visual Studio Server Explorer.

Microsoft Azure HDInsight HQL Service 2.0.6000.0
Language service for Hive query

Microsoft Azure HDInsight Tools for Visual Studio 2.0.6000.0
An integrated development environment for HDInsight application development.

Microsoft Azure Mobile Services Tools 1.4
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2015 - v2.9.40323.3

Microsoft Azure Tools 2.8
Microsoft Azure Tools for Microsoft Visual Studio 2015 - v2.8.31121.1

Node.js Tools 1.1.40329.04
Adds support for developing and debugging Node.js apps in Visual Studio

Node.js Tools - Profiling 1.1.40329.04
Profiling support for Node.js projects.

NuGet Package Manager 3.4.1
NuGet Package Manager in Visual Studio. For more information about NuGet,
visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer 1.2
Microsoft Visual Studio extension to visualize aggregated summaries from
the PreEmptive Analytics product.

SQL Server Data Tools 14.0.60311.1
Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0
Hosting json editor into a tool window

TypeScript 1.8.29.0
TypeScript tools for Visual Studio

Visual Studio Tools for Apache Cordova Update 8
Visual Studio Tools for Apache Cordova

Xamarin 3.11.458.0 (7acdedd)
Visual Studio extension to enable development for Xamarin.iOS and
Xamarin.Android.

Xamarin.Android 5.1.1.0 (3518c4ceb984ffea1f5d972ea9c09eb27738d565)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS 8.10.0.0 (7741cc495ab0baf04ff0405d0604bc27f0ecae2e)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration 1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration 1.0
Early preview of Xamarin Test Cloud integration

Lastly, find attached my project. It's all internet tuturial code to teach
myself angular / node.js. There is nothing proprietary (or terribly
interesting) about it. Please note that when I saw the exceptions before
it was not on this project as I just created it a few days ago. I do not
remember what I would have been working on at the time.

I left my mercurial repository and .vs directory in there just in case
those are involved somehow.

Please let me know if there's anything I can do to help.

-Dave

On 6 April 2016 at 18:11, Steve Cadwallader notifications@github.com
wrote:

Thanks for the extra details, especially that you were using a
Node.JS/Express solution. I have now reproduced the repeated warning
messages, but not the hang.

NTVS (Node.JS Tools for Visual Studio) does not implement part of the VS
API the same as other languages.. which results in the error messages being
created. See #107 #107
and #175 #175 for some
background on the issue we encountered when originally adding support for
NTVS. The workaround is that these methods all have fallback behavior and
provide the warning.

Since these are "known" exceptions in some scenarios, I have demoted them
to only appear when Diagnostics Mode (within CodeMaid->Options) is enabled.

Since I didn't reproduce the hang, I don't know if this will address the
issue you are seeing. Would you mind testing the latest CI build at
http://vsixgallery.com/extension/4c82e17d-927e-42d2-8460-b473ac7df316/
(10.0.76 or higher) to see if that changes the behavior at all?

If it doesn't address the issue (which wouldn't surprise me), then this
would be a similar issue to #227
#227 where the
repeated checking of command availability is causing issues.. and I might
consider keeping the commands permanently enabled vs. dynamically
enabling/disabling them. That would bypass some state checks until on
demand vs. on API demand which is triggered pretty frequently.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#255 (comment)

@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Apr 7, 2016

Thanks for the testing and additional details.

  1. Can you try disabling CodeMaid's diagnostics mode? That should get rid of most of the output messages. I still expect that you'll see the hang, but it would be good to rule out anything with the logging mechanism.
  2. I don't see the repository you mentioned is attached.. can you share that again?
@montgomerybc

This comment has been minimized.

montgomerybc commented Apr 7, 2016

I will try disabling logging.

Mercurial stores its repository in the .hg folder in that zip.

Thanks.

-Dave

On 7 April 2016 at 04:26, Steve Cadwallader notifications@github.com
wrote:

Thanks for the testing and additional details.

  1. Can you try disabling CodeMaid's diagnostics mode? That should get
    rid of most of the output messages. I still expect that you'll see the
    hang, but it would be good to rule out anything with the logging mechanism.
  2. I don't see the repository you mentioned is attached.. can you
    share that again?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#255 (comment)

codecadwallader added a commit that referenced this issue Apr 9, 2016

#227 #255 #268: Change commands that have expensive availability chec…
…ks to remain enabled, deferring availability checks to execution time.
@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Apr 9, 2016

I've changed several of the commands that have expensive availability checks to remain enabled and defer availability checks to execution time. I think this may resolve the issue you have been seeing. Can you please test the latest CI build (10.0.81 or higher) available here: http://vsixgallery.com/extension/4c82e17d-927e-42d2-8460-b473ac7df316/

@montgomerybc

This comment has been minimized.

montgomerybc commented Apr 9, 2016

That is perfect. Exceptions are gone, also the repeating warnings about
.jade files are gone too. Thanks.

Also, CodeMaid has nothing to do with the hanging I have been. Even with
it disabled I see the hang. Thanks for your help.

-Dave

On 9 April 2016 at 04:53, Steve Cadwallader notifications@github.com
wrote:

I've changed several of the commands that have expensive availability
checks to remain enabled and defer availability checks to execution time. I
think this may resolve the issue you have been seeing. Can you please test
the latest CI build (10.0.81 or higher) available here:
http://vsixgallery.com/extension/4c82e17d-927e-42d2-8460-b473ac7df316/


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#255 (comment)

@codecadwallader

This comment has been minimized.

Owner

codecadwallader commented Apr 9, 2016

Excellent, thanks for confirming. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment