project-system
project-system copied to clipboard
Determine the project context when opening the RESX designer
Currently, when you open a .resx file in the designer on a cloud-connected client there is no way to tell what project the file is associated with. This creates the following known limitations in the designer experience:
- The user is unable to switch between "public" and "internal" access. This is because doing so requires we change the generator used, which requires updating metadata on the item in the project file.
It probably causes other limitations as well (not yet verified):
- The user is probably unable to add files as resources, as we don't know which project to add the file to.
Some other component (AnyCode?) will need to provide an API to determine the project on the client side. This task tracks using that information in the designer to find the project and file (that is, the IVsHierarchy for the project, and the ItemID for the file in the hierarchy) on the server, and any other updates that need to be made.
The context is missing because on nexus client Editors receive IVsHierarchy from Miscellaneous Files Project which means that the itemID doesn't belong to any project. This is by design, so a lot of refactor is needed in ProjectSystem to handle nexus and non-nexus.
ProjectModelQueryableSpace
from CPS can help us to fetch some information from the server.
In Nexus client, this is the list of APIs that are broken in Editor Resource Designer:
-
IVsProject
GetItemContext
()GetMkDocument
() -
Hierarchy
GetProperty
()GetGuidProperty
() -
Project
DTE
UniqueName
Kind
Name
Properties
CodeModel
Object
FullName
ProjectItems
-
ProjectItem
FileNames
FileCount
Properties
ProjectItems
Name
Collection
Kind
ContainingProject
Delete
()Remove
() -
ProjectItems
parent
counts
Item
AddFromFile
()AddFromDirectory
()AddFolder
()AddFromFileCopy
() -
IVsTrackProjectDocuments2
AdviseTrackProjectDocumentsEvents
()UnadviseTrackProjectDocumentsEvents
() -
IVsRefactorNotify
OnBeforeGlobalSymbolRenamed
()OnGlobalSymbolRenamed
()OnBeforeAddParams
()OnAddParams
()OnBeforeReorderParams
()OnReorderParams
()OnBeforeRemoveParams
()OnRemoveParams
()
This work item AzDO will fix part of the context on the client https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1178677
Using RESX without WinForms
Related to this .resx issue, it would be great if the .resx Designer/GUI could be updated/modernized to stop producing WinForms references when a .resx file is used in a non-WinForms .csproj targeting NETFW 5 (SDK-style .csproj). Note resx does not require WinForms, but currently the Designer/GUI for it is creating resx files that do contain references to "System.Windows.Forms.dll", although resx could also be used outside of WinForms.
Currently the resx Designer/GUI in VS 16.8.3 produces resx files that do contain references to WinForms like this example:
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="DgmlGraph" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\DgmlGraph.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
Ideally the resx Designer/GUI should only produce WinForms references when it is for a project targeting WinForms, not when it is used in a Console project with SDK/NETFW/5.
resx is useful, especially for the purpose of performing culture/language localizations. It would be great to see an updated version of the resx Designer that is suited for non-WinForms .csproj's that use NETFW 5 (SDK-style .csproj), including Console projects and ASP.NET 5 projects etc.
See also my detailed resources notes in the later message in https://github.com/dotnet/project-system/issues/4534#issuecomment-751579541
This work is not needed, since this is for the client-server architecture.