Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 `<auto-generated>` comment header in every generated `.cs` file.

### Version: 0.5.1
#### Date: Jan-12-2026

Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<auto-generated>` 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.

Expand Down
24 changes: 20 additions & 4 deletions contentstack.model.generator/ModelGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,18 @@ 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 = @"using System;
private readonly string _templateStart = @"// <auto-generated>
// 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
// </auto-generated>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -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 = @"// <auto-generated>
// 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
// </auto-generated>
using System;
using Newtonsoft.Json;
using Contentstack.Core;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -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;");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
<PackAsTool>true</PackAsTool>
<PackageOutputPath>./nupkg</PackageOutputPath>
<PackOnBuild>true</PackOnBuild>
<PackageVersion>0.5.1</PackageVersion>
<PackageVersion>0.5.2</PackageVersion>
<Authors>Contentstack</Authors>
<ReleaseVersion>0.5.1</ReleaseVersion>
<ReleaseVersion>0.5.2</ReleaseVersion>
<RootNamespace>Contentstack.Model.Generator</RootNamespace>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageReleaseNotes>Improved Error messages</PackageReleaseNotes>
<PackageReleaseNotes>Document required NuGet packages in README and generated file headers</PackageReleaseNotes>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<PackageTags>v0.5.1</PackageTags>
<PackageTags>v0.5.2</PackageTags>
<Configurations>Release;Debug</Configurations>
</PropertyGroup>

Expand Down
Loading