Skip to content
Discussion options

You must be logged in to vote

Implementing [ExistingPath] and [ExistingFile] in Metalama requires understanding how these contracts interact. The key challenge is that [ExistingFile] typically validates a file path relative to a directory marked with [ExistingPath]. But normal contracts in Metalama are self-contained - they cannot reference each other.

This can be implemented using a three-aspect pattern:

  1. [ExistingPath] - A marker attribute for directory parameters
  2. [ExistingFile] - A marker attribute for file parameters
  3. PathValidationAspect - The implementation aspect that performs the actual validation

Here's an implementation (not compiled or tested):

using Metalama.Framework.Aspects;
using Metalama.Framework.Code;

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@nolme
Comment options

@gfraiteur
Comment options

@nolme
Comment options

Answer selected by gfraiteur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants