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

GSoC: Source Generation Analyzer Powered by Corvus.JsonSchema (.Net) #614

Open
gregsdennis opened this issue Feb 5, 2024 · 22 comments
Open
Labels
gsoc Google Summer of Code Project Idea

Comments

@gregsdennis
Copy link
Member

gregsdennis commented Feb 5, 2024

Source Generation Analyzer Powered by Corvus.JsonSchema (.Net)

Brief Description
The JSON Schema implementation Corvus.JsonSchema operates by generating source code for types based on a supplied JSON Schema such that the validation constraints present in the schema are rendered in code. An overview of how it works can be found in this video.

Often, different software development teams within a single organization will use different tech stacks to implement their functionality. JSON Schema can help unify these teams by providing a single source of truth for data modelling. The teams will then generate code for the data models.

Extended Description
Please see this comment

Expected Outcomes
This project is to wrap the code generation functionality of the Corvus library in a .Net source generation analyzer to assist developers by easily generating data models using JSON Schema as a source of truth.

Skills Required

Mentors

Expected Difficulty
Medium, if the candidate is familiar with source generators. Hard otherwise.

Expected Time Commitment
175 (minimum, probably)

Expressing interest
If you would like to help with this project, please express your interest in a comment below and read through and complete the Qualification Task and be sure to follow the Contributor Guidance.

@benjagm benjagm changed the title Source Generation Analyzer Powered by Corvus.JsonSchema (.Net) GSoC: Source Generation Analyzer Powered by Corvus.JsonSchema (.Net) Feb 5, 2024
@benjagm benjagm added the gsoc Google Summer of Code Project Idea label Feb 5, 2024
@Kombaiya-MK
Copy link

Hi @gregsdennis , I would like to know more about this issue. Can you please elaborate on what exactly needs to be done?

@gregsdennis
Copy link
Member Author

gregsdennis commented Feb 23, 2024

We're still working some of this out, but off of the top of my head:

Corvus.JsonSchema is currently only a dotnet tool, meaning it can only be used on the command line. This project seeks to add an incremental source generator (recommend watching the video linked above) that can take the code generated by the tool and insert it into a users' source for compilation.

It's likely this can be added to the same Nuget package, though this will need to be researched and confirmed. If it can be, then probably no edits to the exiting code will be needed; just the addition of the analyzer and updating the package accordingly. If not, then there will likely need to be some refactoring of existing code to expose some API. @mwadams can likely provide insights on the existing code.

Ideal user experience

Ideally, it will function similarly to the [JsonSerializable] attribute (and context) already in use by System.Text.Json. I invision something like

[GenerateFromSchema("path/to/schema.json")]
public partial class MyModel;

or even

[assembly:GenerateModelsFromSchema(Schema: "path/to/schema.json", NameSpace: "MyProject.Models")]

You can't put attributes on namespaces, unfortunately, so the target will need to be specified in a string.

I'm not attached to either of these approaches and am open to others, but I think the assembly-level attribute will likely be the most user-friendly.

The attribute itself will be unconditionally source-generated (again, see the video), which will make it available for use immediately upon installing the Nuget package into the target project.

@Kombaiya-MK
Copy link

Thank you for your detailed explanation @gregsdennis.I'll explore both options and any other possibilities, and I'll get back to you.

@gregsdennis
Copy link
Member Author

gregsdennis commented Feb 24, 2024

We still need to wait for other interested contributors. There's still some selection process that we have to go through.

Feel free to read up and mull things over, but don't put any effort into this until we're ready to go.

Please join the #gsoc channel in Slack for more info and coordination.

@benjagm
Copy link
Collaborator

benjagm commented Feb 27, 2024

Thanks a lot for joining JSON Schema org for this edition of GSoC!!

Qualification tasks will be published as comments in the project ideas by Thursday/Friday of this week. In addition I'd like to invite you to a office hours session this thursday 18:30 UTC where we'll present the ideas and the relevant date to consider at this stage of the program.

Please use this link to join the session:
🌐 Zoom
📅 20124-02-29 18:30 UTC

See you there!

@gregsdennis
Copy link
Member Author

gregsdennis commented Feb 28, 2024

Qualifying Task

To qualify for this project, we ask that you perform the tasks below. A .Net solution has been provided to get you started.

In this solution there are three projects: CorvusQualification, ExistingPackage, UserCode.

  1. CorvusQualification does not compile because it uses an attribute that does not exist. Your first task is to update ExistingPackage by adding an incremental source generator that produces the missing attribute. Once the solution compiles this task is complete.

  2. Update ExistingPackage to produce a nuget package that, once installed, allows the user to use ServiceProvider and generates the attribute. Install this package into UserCode and use the attribute as shown in CorvusQualification.
    JsonSchema.GSoC2024.CorvusQualification.zip

    IMPORTANT UserCode must not contain a project reference to ExistingPackage; it must consume the nuget package. DO NOT UPLOAD YOUR PACKAGE TO NUGET.ORG AS THIS WILL IMPACT OTHER CANDIDATES.

  3. Write a readme for the project describing how a user would install the ExistingPackage nuget package and make use of the attribute.


The completed work will need to be submitted via the GSoC platform. Instructions for this can be found in the contributor guidelines.

@mathanraj0601
Copy link

Hi @gregsdennis , Task is interesting will DM you with solution asap : )

@Kombaiya-MK
Copy link

Kombaiya-MK commented Feb 29, 2024

Hi @gregsdennis
Could you please provide me with the due date for the task?

@mathanraj0601
Copy link

Hi @gregsdennis,

I recently watched the video on high-performance JSON serialization, where they used a pre-defined class to generate code for a JSON context, effectively avoiding reflection. the generator dealt witth JSON data .

For our qualification task, we need to work with a JSON schema. Could you provide a demo schema.json that guides us in extracting key details, such as property names and types, using a JSON serializer or another NuGet package? This will assist us in generating a well-structured partial class as generated code.

Thank you!

@gregsdennis
Copy link
Member Author

@mathanraj0601 please just do the task as stated. You don't need any more information than what's given.

Once we get into the project, we'll cover more of what's required for that.

@gregsdennis
Copy link
Member Author

gregsdennis commented Mar 1, 2024

@Kombaiya-MK applications to GSoC are due 18 March, so let's shoot for no later than 11 March. That will give Matt and me time to review the tasks and make a selection.

@Kombaiya-MK
Copy link

@Kombaiya-MK applications to GSoC are due 18 March, so let's shoot for no later than 11 March. That will give Matt and me time to review the tasks and make a selection.

Sure @gregsdennis

@mathanraj0601
Copy link

@mathanraj0601 please just do the task as stated. You don't need any more information than what's given.
Once we get into the project, we'll cover more of what's required for that.

Sure @gregsdennis

@gregsdennis
Copy link
Member Author

Just added a link to the Contributor Guidance in the opening comment. Please read through this and make sure your applications conform to the requirements.

@pranayjoshi
Copy link

Hi mentors,
My exisitinglibrary compiles successfully, but I keep on getting this issue while compiling the Qualification project. I tried different resources and different solutions but none of them work.

error CS0246: The type or namespace name 'GeneratedAttribute' could not be found (are you missing a using directive or an assembly reference?)

My approach:-

  1. Creating a class under Exisiting Library which is a incremental source generator, I made sure to include [Generator].
  2. Create an execute function which contains the GeneratedAttribute in the form of attribute string.
  3. Then just using context.addsource to execute it.

Someone on the stackoverflow suggest that it might be a different version issue. but I don't think so.

@gregsdennis
Copy link
Member Author

The solution as posted above does not compile. The first part of the task is to add an incremental source generator to ExistingLibrary that creates the attribute, allowing the solution to compile.

This is the task that you have to fulfill. I can't provide direction, only clarification.

The "incremental source generators" video linked in the opening comment gives enough information on how to do this.

@pranayjoshi
Copy link

Introductory Questions

Hi everyone, this is Pranay. I am a Full-Stack Developer currently working as a GIS Engineer at the University of Alabama. I am also voluntarily working as a BCI (Brain Computer Interface) Research Assistant, where I am specifically working on creating an SDK between a Bluetooth headset called MUSE.

  • What interests you most about this project?
    What interests me most about this project is the opportunity to work with C# and .NET development. While I have experience with various languages and technologies, I haven't explored C# or .NET until recently. I was offered a part-time job by the CS department of my college to work on their backend and GIS projects, which primarily use C#. I'll be working with them throughout the spring semester to gain hands-on experience with C# and .NET development, ensuring I'm well-prepared for this project during the summer.

  • As mentors and project coordinators, how can we get the best out of you?
    As mentors and project coordinators, you can get the best out of me by providing constructive criticism. I greatly respect and value feedback on my code, as it helps me improve and write better code. I understand that mentors have their own commitments, so I will consolidate my questions and send them in one go to avoid frequent disturbances.

  • Is there anything that you’ll be studying or working on whilst working alongside us?
    During the summer, while working alongside you, I plan to work on a few side projects and brush up on my data structures and algorithms skills. However, this will not hinder my commitment to this project, and I will ensure that all tasks are completed by the tentative due dates.

  • We'd love to hear a bit about your work preferences, e.g. how you keep yourself organized, what tools you use, etc?
    Regarding my work preferences, I am well-versed in the Open Source Community, having been a Google Code-in winner from the OSGeo organization, which is also participating in this year's GSOC. I am primarily a Full Stack Developer, proficient in languages and tech stacks such as Golang, React, Python, MERN, Java, C++, Rust, and Vue. I use various tools and techniques to keep myself organized, such as task management applications, version control systems, and code editors.

  • Once you’ve selected a project from the ideas section, please suggest a weekly schedule with clear milestones and deliverables around it.
    I am not sure if I have to answer this question before the proposal. But if I do please let me know.

@gregsdennis
Copy link
Member Author

gregsdennis commented Mar 10, 2024

@pranayjoshi @mathanraj0601 @Kombaiya-MK due to some complications, I've had to update the template solution for the qualification task. Please download the new one (link replaced above). If you've done any work, you should be able to copy it over with some renaming ("ExistingLibrary" -> "ExistingPackage").

@mathanraj0601
Copy link

Sure @gregsdennis

@benjagm
Copy link
Collaborator

benjagm commented Mar 18, 2024

🚩 IMPORTANT INSTRUCTIONS REGARDING HOW AND WHERE TO SUBMIT YOU APPLICATION 🚩

Please join this discussion in JSON Schema slack to get the last details very important details on how to better submit your application to JSON Schema.

See communication here.

@MoMakkawi
Copy link

Hello @gregsdennis , I have knowledge in Roslyn & Source Generators (I worked on many projects, such as my project Organizer-SG) and I contributed to them in .NET. Is it still possible to apply to work on this exciting task?

@gregsdennis
Copy link
Member Author

@MoMakkawi the deadline for applications is 2 Apr. If you can submit before then, you're welcome to. Join #gsoc in slack. Instructions are in the history there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gsoc Google Summer of Code Project Idea
Projects
None yet
Development

No branches or pull requests

6 participants