microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
219 stars 9 forks source link

Resource files do not update the designer #999

Open mmiller-d8 opened 5 months ago

mmiller-d8 commented 5 months ago

Type: Bug

When modifying a resource xml file for localization, it does not update the designer.cs file upon saving. This is kind of a deal breaker.

Right now, I'm having to bounce between VS Code and Visual Studio for Mac. I quite enjoy the C# editing experience even though it still has a ways to go, but the Xaml and other Maui bits feel like an Alpha release. If that, even.

Extension version: 0.9.7 VS Code version: Code 1.87.2 (863d2581ecda6849923a2118d93a088b0745d9d6, 2024-03-08T15:20:57.520Z) OS version: Darwin arm64 23.2.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Apple M3 Max (14 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|8, 5, 5| |Memory (System)|96.00GB (0.21GB free)| |Process Argv|--crash-reporter-id 1618046c-b005-4c1a-89ae-cb627902572c| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256860 vstes627:30244334 vscod805:30301674 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 2e7ec940:30986170 pythontbext0:30879054 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:30979542 8082a590:30971561 fegfb526:30981948 bg6jg535:30979843 ccp1r6:30958156 dsvsc020:30976470 7ghi1836:30988842 ```
arkalyanms commented 5 months ago

@mmiller-d8 would you be able to share a repro'able project?

Michael-Eng commented 5 months ago

Adding area-project to consider

tmeschter commented 5 months ago

@mmiller-d8 Also, is the .designer.cs file updated during a build?

mmiller-d8 commented 5 months ago

@arkalyanms @tmeschter

It is not updating when I build it either, unfortunately. I created a new project that repros it. I created the project in Visual Studio and made sure it ran, then I added a new resource file with one value. It updated as it should in Visual Studio. Then I closed it and opened it in VS Code. I added another value and it did not update the designer. I built and ran the project, and it still didn't update the file.

I tried updating it in both the file explorer and the solution explorer. Neither one worked.

The repo is here

Oh, and I probably should have mentioned that this is a .Net Maui project. I just tried in with and Asp.Net project and it didn't work either.

mauroa commented 5 months ago

Removing "area-maui" since it doesn't look like MAUI specific, according to latest user comments

DeerSteak commented 5 months ago

Is there a workaround for this, other than opening the project and rebuilding it in Visual Studio?

mmiller-d8 commented 5 months ago

@DeerSteak Luckily, you don't have to rebuild. Just do the edits in VS and save it. It updates the resource designer and VS Code picks up the change. It's a pain that you have to flip back and forth, but it works.

DeerSteak commented 5 months ago

@mmiller-d8 that's awesome, thanks. Guess I need to reinstall VS for Mac.

timheuer commented 4 months ago

@maddymontaquila this doesn't build even the resources on dotnet build the resources are using a generator that doesn't seem to be working...is something in the MAUI SDK failing?

<EmbeddedResource Update="Resources\Localization\AppResources.resx">
        <Generator>PublicResXFileCodeGenerator</Generator>
        <LastGenOutput>AppResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
viniciusjarina commented 4 months ago

This is a important feature for localization that was done by VSMac/MonoDevelop https://github.com/mono/monodevelop/blob/main/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CustomTools/ResXFileCodeGenerator.cs. And really make using VS Code for C# more painful.

It should be ported to C# DevKit, or maybe extracted as a custom MSBuild Task and run during the build.

It seems Rider handle it properly re-generating the Strings.designer.cs when you add a string.

jfversluis commented 1 month ago

Just ran into this, this seems like something important as without it its impossible to localize .NET MAUI apps when VS for Mac goes out of support. Or you'd have to do things manually, which seems crazy. Just leaving my +1 here!

bfunk-tt commented 1 month ago

Until this gets fixed in tools, David Ortinau has a workaround for your csproj to auto-generate resource files:

https://github.com/davidortinau/SentenceStudio/blob/main/src/SentenceStudio/SentenceStudio.csproj#L145-L158

You can follow a similar pattern. It works in my case, which is nice.