so i have some blazor clientside project
so as i should i have lets say person.cs
in shared project so it can be used both in client and server side - by design it is correct place for such class... ?
now in client side i have MudBlazor
as component library
so now as they have an option to automaticly set labels on components based on attribute as here https://mudblazor.com/components/form#automatically-set-labels
so i need to have like
sharedproject/person.cs
public class person{
[Label("enter name")]
public string name {get;set;}
}
and it yealds at me because shared project has no idea about this MudBlazor LabelAttribute
so what would be best solution here? install mudblazor in shared project? is it good option ?
or not use this attribute in such cases?
i need this class in both client and server project
creating second 'derived' is option but it will be same class just with the [labels]
so not best option imho also?
please advise best regards
I think that you are right, the correct place for DTO classes used by both Client and Server, is a shared project.
Maybe the clean solution is to have 'derived' classes, but it is easiest to install MudBlazor in the shared project. In that case you'll have this dll in you API project but don't need to duplicate all of your DTO classes.
IMHO MudBlazor should give a "Global" configuration where you can define if use their custom attribute "Label" or the generic one "Display", this way it would be possible to use in a shared project the "Display" attribute without the need to install MudBlazor.
That was discussed in those topics: