Serenity
Serenity copied to clipboard
If you have recently defined this enum type in server side code, make sure your project builds successfully and transform T4 templates.
PLEASE ENSURE ABOUT ALL FIELDS FILLED
- [x] This isn't a feature request or a discussion topic
- [x] I have searched open and closed issues for duplicates
- [x] I am searched documents on https://serenity.is/docs/
- [x] I have read https://serenity.is/docs/startsharp/faq
- [x] I have to use descriptive issue title
- [x] I approve to fill in the information below
Describe the bug Error message: If you have recently defined this enum type in server side code, make sure your project builds successfully and transform T4 templates.
According to documentation, this happens automatically now. I'm using .NET 5.0. I do not have any option to manually "transform t4 templates", so I'm not sure what I'm supposed to do about this.
The namespace is correct, as per your documentation in the Movie Database Tutorial. I have no clue what I should be looking at, the documentation just says to "transform t4 templates" which supposedly happens automatically now, and no option exists in Rider or Visual Studio to do so.
To Reproduce
- Follow MovieDatabase Tutorial
- Create a MovieKind enum per tutorial
- Try to build the project & open the dialog
- See error
Expected behavior It shouldn't error, and the enum should be used.
Screenshots If applicable, add screenshots to help explain your problem.
**Serenity Versions
- Serene Template Version (when reproduced on Serene Template)
- Sergen Version (if required)
- Installed Serenity Nuget Packages Versions (you can find them in csproj)
Additional context Add any other context about the problem here.
The message needs to be updated. Add [ScriptInclude]
attribute on your enum.
The message needs to be updated. Add
[ScriptInclude]
attribute on your enum.
using Serenity.ComponentModel;
using System.ComponentModel;
namespace MovieTutorial.MovieDB
{
[ScriptInclude]
[EnumKey("MovieDB.MovieKind")]
public enum MovieKind
{
[Description("Film")]
Film = 1,
[Description("TV Series")]
TvSeries = 2,
[Description("Mini Series")]
MiniSeries = 3
}
}
Is this proper placement? If so, it still results in the same error after a rebuild.
Ensure about your build is successful. And if you still have issues with this, use discussions instead. I preserve this issue for fixing the error message.
You still can transform T4 templates manually: Right click on your MovieTutorial.Web Project -> Open in Terminal -> Type in "dotnet sergen t" (without quotation marks) and hit Enter. In my project I never needed neither [ScriptInclude] nor [EnumKey] attribute but worked anyway. Sometimes it helps to delete the folders Imports/ClientTypes and Imports/ServerTypings and manually recreate T4 templates. Renaming a class or enum is often the cause for trouble with T4 templates.