dotnet / project-system

The .NET Project System for Visual Studio
MIT License
971 stars 388 forks source link

Generated resource code file #502

Open alrz opened 8 years ago

alrz commented 8 years ago

It'd be nice if .resx generates code like .xaml files (e.g. .g.cs files) so that they wouldn't be part of the project, therefore, merge conflicts only require to be resolved in the source .resx file.

(Not sure if this is the right place for this)

davkean commented 8 years ago

Yep, thanks for the suggestion. It's a great idea and one we've spoken about before.

MarkPflug commented 8 years ago

I second this request! It would be nice to have a compiler-integrated solution that could work from a command line build as well. SingleFileGenerators (the VS feature behind resx code-gen) require Visual Studio, and the resultant code ends up being included in the project and source control, even though I wouldn't consider it to be source code. One could use a custom MSBuild task to perform the code-gen (which is how Xaml does it), but if the generated code is going to be consumed by the rest of the project you won't get intellisense for the generated code in Visual Studio.

It seems like the "generators" feature could provide this functionality, but it seems more concerned with aspect oriented programming (even though the description doesn't use those words) than being a replacement for SFGs. https://github.com/dotnet/roslyn/blob/master/docs/features/generators.md

I suspect that one could hack together a working solution using generators.

[ResxCodeGen("Resources.resx")] // indicator to the Resx generator what input file to process
static class CodeGenHack {} // just a place to attach the attributes.

Perhaps this is a roslyn issue and not a project system issue.