FormatterAttribute build error and wrong auto generation #7283
Replies: 2 comments 11 replies
-
You don't need to write formatter attribute. Just write the formatter in typescript and build project, attribute should be generated automatically. Then use the auto generated attribute. |
Beta Was this translation helpful? Give feedback.
-
As you can see below, I added I wrote code in UserDialog.ts file but it better on separated file. |
Beta Was this translation helpful? Give feedback.
-
After I opened new project. While it is empty , I tried to write a new formatter. So I checked sample codes then I write a formatter. But project is not build after all.
I know it is a simple task, but I cannot worked it.
I read the another topics. It may caused from node.js . Then I removed node.js and installed it but nothing changed.
by the way sergen is working.
When I closed my code. Everything is fine.
and Another suspicion is wheren I changed namespace EmployeeFormatterAttribute.cs
from Kaptan.Administration to Kaptan.Administration.Formatter . Evertthing is fine but I added step6 auto generated code and Image .
There is no my GenderProperty in generated code.
Something goes wrong.
step1
.cs file code is;
namespace Kaptan.Administration;
public partial class EmployeeFormatterAttribute : CustomFormatterAttribute
{
public const string Key = "Kaptan.Administration.EmployeeFormatter";
}
step2
.ts file code is ;
import { Decorators, Formatter, IInitializeColumn, isTrimmedEmpty } from "@serenity-is/corelib";
import { Column, FormatterContext } from "@serenity-is/sleekgrid";
@Decorators.registerFormatter('Kaptan.Administration.EmployeeFormatter', [IInitializeColumn])
export class EmployeeFormatter implements Formatter {
constructor(public readonly props: { genderProperty?: string } = {}) {
this.props ??= {};
}
}
step3.
attribute usage code is ;
step4
error is;
Error CS0111 Type 'EmployeeFormatterAttribute' already defines a member called 'EmployeeFormatterAttribute' with the same parameter types
...\Kaptan.Web\Serenity.Pro.Coder\Serenity.Pro.Coder.ClientTypesSourceGenerator\Administration.EmployeeFormatterAttribute.generated.cs 13 Kaptan.Web Active
Error CS0102 The type 'EmployeeFormatterAttribute' already contains a definition for 'Key' ...\Kaptan.Web\Serenity.Pro.Coder\Serenity.Pro.Coder.ClientTypesSourceGenerator\Administration.EmployeeFormatterAttribute.generated.cs 11 Kaptan.Web Active
Error CS0229 Ambiguity between 'EmployeeFormatterAttribute.Key' and 'EmployeeFormatterAttribute.Key' ...\Kaptan.Web\Modules\Administration\User\EmployeeFormatterAttribute.cs
Build message is;
Step5;
usage code is ;
namespace Kaptan.Administration.Columns;
[ColumnsScript("Administration.User")]
[BasedOnRow(typeof(UserRow), CheckNames = true)]
public class UserColumns
{
..
...
}
usage image is ;
step6
auto generation code is ;
This file is auto-generated by the generator 'Serenity.Pro.Coder.ClientTypesSourceGenerator' and cannot be edited.
...
...
.
namespace Kaptan.Administration
{
public partial class EmployeeFormatterAttribute : CustomFormatterAttribute
{
public const string Key = "Kaptan.Administration.EmployeeFormatter";
}
as a image;
Beta Was this translation helpful? Give feedback.
All reactions