Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore possibility of Source Generators for JSON-LD support #5

Closed
warriordog opened this issue Jun 23, 2023 · 2 comments · Fixed by #22
Closed

Explore possibility of Source Generators for JSON-LD support #5

warriordog opened this issue Jun 23, 2023 · 2 comments · Fixed by #22
Labels
area:code Affects or applies to the library code

Comments

@warriordog
Copy link
Owner

This is to explore a possible implementation of JSON-LD based on interfaces and Roslyn Source Generators. If successful, this will resolve #2.

The first step is to model all AP / AS types as interfaces rather than classes. This accomplishes two key things:

  • Resolves multiple inheritance (as with OrderedCollectionPage)
  • Allows an application to include multiple extensions of the native types

And has two key flaws:

  • You can't create an instance of an interface
  • Library users would have to manually define an implementation for every type they use

Both flaws are dealbreakers, which leads to the second step - implementing a source generator. The source generator will automatically produce all necessary implementation classes at compile time. Since this runs at application compile time, rather than library compile time, the implementation class is guaranteed to have all fields supported by the application. Application users would just need to create an empty partial class for each type needed.

@warriordog warriordog added the area:code Affects or applies to the library code label Jun 23, 2023
@warriordog warriordog self-assigned this Jun 23, 2023
@warriordog
Copy link
Owner Author

Downside: can't model case where a type "may" include an extension

@warriordog warriordog removed their assignment Jun 23, 2023
@warriordog
Copy link
Owner Author

Impossible to implement efficiently using the temporary rewrite described in #21. This item is therefore blocked indefinitely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:code Affects or applies to the library code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant