OneOf
OneOf copied to clipboard
Source generator should work for nested types
It looks like the source generator doesn't work for nested classes.
works as expected
[GenerateOneOf]
public partial class Result : OneOfBase<string, string> {}
does not work
public class MyClass {
[GenerateOneOf]
public partial class Result : OneOfBase<string, string> {}
}
Or am I doing something wrong? I'm no expert with source generators, but I believe it should be possible to configure the generator to pick up nested types too.
Thanks!
source generator simply generates new .cs files and you cant generate file that matches this:
public class MyClass
{
[GenerateOneOf]
public partial class Result : OneOfBase<string, string> {}
}
for example this code does not compile:
public class A
{
public partial class B { }
}
public class A
{
public partial class B { }
}
it would result in compile time error. it could theoretically be possible to generate a matching file when class is nested in another partial class eg:
public partial class MyClass
{
[GenerateOneOf]
public partial class Result : OneOfBase<string, string> {}
}
but for simplicity it was not done :)