project-system icon indicating copy to clipboard operation
project-system copied to clipboard

Block retrieving ProjectItem.FileCodeModel and Project.CodeModel until Roslyn is aware of the file

Open davkean opened this issue 8 years ago • 8 comments

We should block retrieving ProjectItem.FileCodeModel/Project.CodeModel until Roslyn has become aware of the file. This lets us provide the same guarantee as the legacy project system. Useful for extensions and wizards.

When testing this, please check two cases:

  • [ ] When a Code Diagram is part of the "active" restored documents it displays an error due to CodeModel returning null.
  • [ ] https://github.com/dotnet/project-system/issues/2999#issuecomment-389762981
  • [ ] Reenable code fix in Roslyn that renames file to match type name

davkean avatar Jul 03 '17 01:07 davkean

We should make this work:

at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.InvisibleEditor..ctor(IServiceProvider serviceProvider, String filePath, IVisualStudioHostProject projectOpt, Boolean needsSave, Boolean needsUndoDisabled)
at Microsoft.VisualStudio.LanguageServices.RoslynVisualStudioWorkspace.OpenInvisibleEditor(IVisualStudioHostDocument hostDocument)
at Microsoft.VisualStudio.LanguageServices.RoslynVisualStudioWorkspace.OpenInvisibleEditor(DocumentId documentId)
at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.FileCodeModel.InitializeEditor()
at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.FileCodeModel.EnsureEditor[T](Func`1 action)
at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.FileCodeModel.AddClass(String name, Object position, Object bases, Object implementedInterfaces, vsCMAccess access)
at EnvDTE.FileCodeModel.AddClass(String Name, Object Position, Object Bases, Object ImplementedInterfaces, vsCMAccess Access)

davkean avatar Jul 03 '17 01:07 davkean

Hello. Mr. Davkean. I am the one who raised the same issue in #3596. in my visx application, using .net core with FileCodeModel is critical part. is there no work-around to use FileCodeModel for .net core project? I need to release my vsix application asap.

junimnjw avatar Jun 13 '18 23:06 junimnjw

There is no workaround.

davkean avatar Jun 14 '18 00:06 davkean

Moving to 16.1 because the API that we depend on is on 16.1 #3425

jjmew avatar Dec 18 '18 00:12 jjmew

👃🏻

weitzhandler avatar Oct 04 '20 05:10 weitzhandler

The fix for this will be similar enough to #3425 that we should consider fixing both at the same time.

drewnoakes avatar Dec 09 '22 02:12 drewnoakes

@drewnoakes I think there might be other cases of this, such as TempPE code that @davidwengier wrote.

davkean avatar Dec 09 '22 03:12 davkean

Two more places we have called this out:

https://github.com/dotnet/project-system/blob/f11b6d17601e4e0ffe20776982dcd586a3358712/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Rename/FileMoveNotificationListener.cs#L223-L227

https://github.com/dotnet/project-system/blob/f11b6d17601e4e0ffe20776982dcd586a3358712/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Rename/RenamerProjectTreeActionHandler.cs#L146-L152

drewnoakes avatar Dec 23 '22 00:12 drewnoakes