I\'ve been working on a language, but in terms of .NET integration I\'ve only managed to get primitive types working so far. Last night I had a good idea - instead of trying to
A standard way of augmenting type information with extra data in .NET would be to use attributes, though attribute constructor arguments would normally be limited to values you can represent as literals. This may or might not be an issue for you, depending on how rich you would your metadata to be. DU's probably won't work.
Otherwise, a straightforward solution would be to wrap your value together with arbitrary metadata into a generic type, i.e.
type TypeWithMetadata<'typ, 'metadata>(value: 'typ, metadata: 'metadata) =
member this.Value = value
member this.Metadata = metadata
though that might come with an overhead you'd want to avoid?