1

Here is the resource file in aspnetcore repo. https://github.com/dotnet/aspnetcore/blob/main/src/Identity/Extensions.Core/src/Resources.resx

The usage of it is in: https://github.com/dotnet/aspnetcore/blob/main/src/Identity/Extensions.Core/src/IdentityErrorDescriber.cs

I wanna know how it generates the Resource class, to have the methods like Resources.FormatInvalidUserName(userName). Which is especially useful when formatting string.

The default behavior of code generation in visual studio 2022 does not generate method like above. It will only generate properties. I have to call string.Format to format the string.

A clue is the custom tool of aspnetcore's is MSBuild:_GenerateResxSource while mine is PublicResXFileCodeGenerator.

Please tell me how to generate code like aspnetcore repo.

I tried to edit the custom tool from PublicResXFileCodeGenerator into MSBuild:_GenerateResxSource. But it does not work.

Kumima
  • 11
  • 1
  • I was answering similar question recently here: https://stackoverflow.com/a/76080384/7167572 It might bring some ideas/better understanding? – Tatranskymedved May 14 '23 at 19:23

0 Answers0