Skip to content

Latest commit

 

History

History
59 lines (36 loc) · 2.16 KB

File metadata and controls

59 lines (36 loc) · 2.16 KB

ExistingPackage NuGet Package - Usage Instructions

This readme provides instructions on how to use the ExistingPackage NuGet package, which includes a GeneratedAttribute and the ServiceProvider functionality.

Usage in Your Project:

  • Now that the ExistingPackage NuGet package is installed in your project, follow these steps to use the included features:

Declaring the GeneratedAttribute

  1. In your project, import the namespace where the generated attribute is used:
using JsonSchema.GSoC2024.ExistingPackage;
  1. Now, declare the generated attribute with two string parameters, where the first parameter is the path to a JSON schema file, and the second parameter is the namespace (JsonSchema.GSoC2024.CorvusQualification).below the namespace
[assembly: Generated("path/to/schema.json", "JsonSchema.GSoC2024.CorvusQualification")]

As the attribute is assembly level it is recommended to use it in assembly info.cs in case of .net framework and create a separate file called assembly info.cs and use it in case of others

assemblyInfo

  1. (Optional) Rebuild the project to create the source code.

  2. (Optional) You can see the autogenerated c# code by ctrl+clickthe attributes :

GeneratedCode

After Successful declaration, you will notice an analyzer under dependencies

Analyzer

Utilizing the ServiceProvider

  • In your project, create an instance of the ServiceProvider class and use it as needed:
using JsonSchema.GSoC2024.ExistingPackage;

namespace YourNamespace
{
    public class YourClass
    {
        ServiceProvider serviceProvider = new ServiceProvider();

    }
}