felipebz / ndapi

A .NET wrapper for Oracle Forms Open API
MIT License
11 stars 3 forks source link

Find a better way to implement metadata-related classes #47

Open felipebz opened 9 years ago

felipebz commented 9 years ago

Currently, the NdapiMetaObject requires the PropertyAttribute in every property of the class, to extract its metadata.

So, a simple property becames:

[Property(NdapiConstants.D2FP_COMMENT)]
public string Comment
{
    get { return GetStringProperty(NdapiConstants.D2FP_COMMENT); }
    set { SetStringProperty(NdapiConstants.D2FP_COMMENT, value); }
}

Ideally, the code would have to be like:

[Property(NdapiConstants.D2FP_COMMENT)]
public string Comment { get; set; }

The getter and setter code would be injected in compile time, calling the right GetProperty and SetProperty.

felipebz commented 9 months ago

Now this can be implemented using a source generator: https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview