From 3c25dacc168bdb11422ecb495d9e30b633e14c38 Mon Sep 17 00:00:00 2001 From: OMpawar-21 Date: Tue, 2 Jun 2026 12:27:14 +0530 Subject: [PATCH 1/2] fix: Fixed the document required NuGet packages for generated code Add comment header to all generated .cs files listing the four required NuGet packages (contentstack.csharp, contentstack.utils, Newtonsoft.Json, Markdig). Add a "Required NuGet Packages" section to README.md with copy-paste install commands and a package-to-namespace reference table. --- README.md | 20 +++++++++++++++++ .../ModelGenerator.cs | 22 ++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 19aaaf5..dc68dc6 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,26 @@ To install Contenstack model generator run following command: dotnet tool install -g contentstack.model.generator ``` +## Required NuGet Packages + +The files generated by this tool depend on the following NuGet packages. You must install them in your **application project** (not the generator itself) before the generated code will compile: + +```bash +dotnet add package contentstack.csharp +dotnet add package contentstack.utils +dotnet add package Newtonsoft.Json +dotnet add package Markdig +``` + +| Package | Provides | +| --- | --- | +| `contentstack.csharp` | `Contentstack.Core` and `Contentstack.Core.Models` namespaces | +| `contentstack.utils` | `Contentstack.Utils.Models` and `Contentstack.Utils.Interfaces` namespaces | +| `Newtonsoft.Json` | `Newtonsoft.Json`, `Newtonsoft.Json.Converters`, `Newtonsoft.Json.Linq` namespaces | +| `Markdig` | Markdown-to-HTML conversion used in `ContentstackStringExtension` | + +> **Note:** Every generated `.cs` file includes an `` comment at the top listing these packages as a reminder. + ## How to use Once you install ```contentstack.model.generator``` run ```--help``` to view available commands. diff --git a/contentstack.model.generator/ModelGenerator.cs b/contentstack.model.generator/ModelGenerator.cs index 3550594..636c1ce 100644 --- a/contentstack.model.generator/ModelGenerator.cs +++ b/contentstack.model.generator/ModelGenerator.cs @@ -71,7 +71,15 @@ public class ModelGenerator [VersionOption("0.5.1")] public bool Version { get; } - private readonly string _templateStart = @"using System; + private readonly string _templateStart = @"// +// Generated by contentstack.model.generator +// This file requires the following NuGet packages to be installed in your project: +// dotnet add package contentstack.csharp +// dotnet add package contentstack.utils +// dotnet add package Newtonsoft.Json +// dotnet add package Markdig +// +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -400,7 +408,15 @@ private void CreateEmbeddedObjectClass(string NameSpace, DirectoryInfo directory { var sb = new StringBuilder(); // Adding using at start of file - var usingDirectives = @"using System; + var usingDirectives = @"// +// Generated by contentstack.model.generator +// This file requires the following NuGet packages to be installed in your project: +// dotnet add package contentstack.csharp +// dotnet add package contentstack.utils +// dotnet add package Newtonsoft.Json +// dotnet add package Markdig +// +using System; using Newtonsoft.Json; using Contentstack.Core; using Newtonsoft.Json.Linq; @@ -1107,8 +1123,8 @@ private void CreateStringHelperClass(string nameSpace, DirectoryInfo directoryIn using (var sw = file.CreateText()) { var sb = new StringBuilder(); - sb.AppendLine("using Markdig;"); sb.AppendLine(_templateStart); + sb.AppendLine("using Markdig;"); sb.AppendLine("using System.ComponentModel;"); sb.AppendLine("using System.Reflection;"); From 64c440b9eab39bbd08945dd245eb39891cae381f Mon Sep 17 00:00:00 2001 From: OMpawar-21 Date: Tue, 2 Jun 2026 13:36:46 +0530 Subject: [PATCH 2/2] fix: Added minor version bump --- CHANGELOG.md | 5 +++++ contentstack.model.generator/ModelGenerator.cs | 2 +- .../contentstack.model.generator.csproj | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7d402e..d41f95d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### Version: 0.5.2 +#### Date: Jun-02-2026 + +- Document required NuGet packages (`contentstack.csharp`, `contentstack.utils`, `Newtonsoft.Json`, `Markdig`) in README and as an `` comment header in every generated `.cs` file. + ### Version: 0.5.1 #### Date: Jan-12-2026 diff --git a/contentstack.model.generator/ModelGenerator.cs b/contentstack.model.generator/ModelGenerator.cs index 636c1ce..cd5d729 100644 --- a/contentstack.model.generator/ModelGenerator.cs +++ b/contentstack.model.generator/ModelGenerator.cs @@ -68,7 +68,7 @@ public class ModelGenerator [Option(CommandOptionType.NoValue, ShortName = "N", LongName = "is-nullable", Description = "The features that protect against throwing a System.NullReferenceException can be disruptive when turned on.")] public bool IsNullable { get; } - [VersionOption("0.5.1")] + [VersionOption("0.5.2")] public bool Version { get; } private readonly string _templateStart = @"// diff --git a/contentstack.model.generator/contentstack.model.generator.csproj b/contentstack.model.generator/contentstack.model.generator.csproj index 7112a5c..be7645b 100644 --- a/contentstack.model.generator/contentstack.model.generator.csproj +++ b/contentstack.model.generator/contentstack.model.generator.csproj @@ -13,15 +13,15 @@ true ./nupkg true - 0.5.1 + 0.5.2 Contentstack - 0.5.1 + 0.5.2 Contentstack.Model.Generator LICENSE.txt - Improved Error messages + Document required NuGet packages in README and generated file headers true true - v0.5.1 + v0.5.2 Release;Debug