[TomlSourceGenerationOptions] is defined as a sealed class such that it cannot be inherited, which is fine. But [AttributeUsage(Inherited = true)] is also defined such that I am forced to define [TomlSourceGenerationOptions] exhaustively on all TomlSerializerContext types, even if all of those types are desired to be using all the same parsing/generation rules.
What I need to do now:
public class Foo
{
public string Bar { get; set; } = "Hello World";
}
[TomlSourceGenerationOptions(
DuplicateKeyHandling = TomlDuplicateKeyHandling.LastWins] // Default is .Error
[TomlSerializable(typeof(Foo))]
public partial class FooContext : TomlSerializerContext { }
public class Alice
{
public string Bob { get; set; } = "Hello Dudes";
}
[TomlSourceGenerationOptions(
DuplicateKeyHandling = TomlDuplicateKeyHandling.LastWins] // Default is .Error
[TomlSerializable(typeof(Alice))]
public partial class AliceContext : TomlSerializerContext { }
I want to be able to aggregate all [TomlSourceGenerationOptions] such that all my toml-serializable classes can be parsed and written with the same basic parsing rules and without all the exhaustive boilerplate on every single ###Context definition.
Something like:
[TomlSourceGenerationOptions(
DuplicateKeyHandling = TomlDuplicateKeyHandling.LastWins]
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class MySpecificTomlOptions : TomlAttribute { }
Such that I can have:
[MySpecificTomlOptions]
[TomlSerializable(typeof(Foo))]
public partial class FooContext : TomlSerializerContext { }
[MySpecificTomlOptions]
[TomlSerializable(typeof(Alice))]
public partial class AliceContext : TomlSerializerContext { }
Is this truly not possible in any way? Issue 129 says I can't instantiate TomlSerializerContext types with user-specified TomlSerializerOptions values, (which is fine and makes sense why), so my thinking was that I could just make a "generic" that I could use as a one-liner that would include all of my [TomlSourceGenerationOptions], but I seem to not be able to do this in literally any way. It would seem like this approach is possible and reasonable in that we're not messing with the compile-time generation stickyness here.
Can this be done? Am I missing something here or is this truly a prohibited ask?
[TomlSourceGenerationOptions] is defined as a sealed class such that it cannot be inherited, which is fine. But [AttributeUsage(Inherited = true)] is also defined such that I am forced to define [TomlSourceGenerationOptions] exhaustively on all TomlSerializerContext types, even if all of those types are desired to be using all the same parsing/generation rules.
What I need to do now:
I want to be able to aggregate all [TomlSourceGenerationOptions] such that all my toml-serializable classes can be parsed and written with the same basic parsing rules and without all the exhaustive boilerplate on every single ###Context definition.
Something like:
Such that I can have:
Is this truly not possible in any way? Issue 129 says I can't instantiate TomlSerializerContext types with user-specified TomlSerializerOptions values, (which is fine and makes sense why), so my thinking was that I could just make a "generic" that I could use as a one-liner that would include all of my [TomlSourceGenerationOptions], but I seem to not be able to do this in literally any way. It would seem like this approach is possible and reasonable in that we're not messing with the compile-time generation stickyness here.
Can this be done? Am I missing something here or is this truly a prohibited ask?