-
This doesn't seem to work: public sealed class Example
{
// ...
[ValueObject]
private partial class Test { }
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Not currently, and I wasn't planning on enabling it. What scenario would you like to use this in? I'm happy to add it for any useful situations. |
Beta Was this translation helpful? Give feedback.
-
I took another look at this. For your scenario to work as intended, the C# compiler would insist that I'm guessing this would open up a huge back door to the safety that you want in your santizer implementation, allowing anyone to extend the type with another partial implementation. I'm torn between disallowing it, which is does currently, or allowing it if all parent types are partial. The tricky things is that the generator would have to keep track of the parent types and whether they're classes, structs, records, readonly structs/record structs etc. etc., e.g. public partial class Layer1
{
internal sealed partial class Layer2
{
public partial struct Layer3
{
public sealed partial record Layer4
{
internal partial record struct Layer5
{
[ValueObject]
public partial class MyVo
{
}
}
}
}
}
} I don't know if the follow suggestion will be of any use to you, but did you know that Vogen allows for 'normalization'? Taking your example above, it would be something like: [ValueObject<string>]
public partial class MySantizedThing
{
private static string NormalizeInput(string input) => input.Replace("bad", "good");
} Normalization happens before Validate is called (if there is a Validate method). |
Beta Was this translation helpful? Give feedback.
I apologize for the large delay in responding (moved apartments).
Someone would be able to add another
ISanitizedContent
implementation, but they wouldn't be able to changeGetSanitizedContent
, as far as I understand.With that said, the implementation complexity on the Vogen side might not justify the effort. For now we're just returning a simple record.
Regarding normalization, I am aware of it. The example that I provided is just one part of a system that processes content with one or more "processors", which also have dependencies. So, it's likely not a good fit.
Thanks for getting back to me about this, but I think we're good for now. 👍