Skip to content

Annotations to mark FromDoc, PostDoc? #52

@grahamboree

Description

@grahamboree

There may be cases where a user wants to use DarkConfig on a type that already has static methods named PostDoc or FromDoc. This would cause issues with DarkConfig's method name reflection-based search, and would require the client code to rename the existing methods to avoid a conflict. This is significantly less likely if we're checking the argument types, since one argument type must be DarkConfig.DocNode, but it's still possible.

Instead, the more canonical approach is likely to mark those special functions with annotations:

class Sample {
  int foo = 42;
  
  [DarkConfig.PostDoc]
  public static Sample PostDoc(Sample sample) {
    sample.foo = 99;
    return sample;
  }
  
  [DarkConfig.FromDoc]
  public static Sample FromDoc(Sample sample, DarkConfig.DocNode doc) {
    return new Sample { foo = doc.As<int>(); };
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    💡 idea📈enhancementA useful improvement or extension to existing behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions