Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export class NewtonsoftCSharpRenderer extends CSharpRenderer {
this.emitType(
undefined,
AccessModifier.Public,
"static class",
"static partial class",
"Serialize",
undefined,
() => {
Expand Down Expand Up @@ -471,7 +471,7 @@ export class NewtonsoftCSharpRenderer extends CSharpRenderer {
this.emitType(
undefined,
AccessModifier.Internal,
"static class",
"static partial class",
converterName,
undefined,
() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ export class SystemTextJsonCSharpRenderer extends CSharpRenderer {
this.emitType(
undefined,
AccessModifier.Public,
"static class",
"static partial class",
"Serialize",
undefined,
() => {
Expand Down Expand Up @@ -484,7 +484,7 @@ export class SystemTextJsonCSharpRenderer extends CSharpRenderer {
this.emitType(
undefined,
AccessModifier.Internal,
"static class",
"static partial class",
converterName,
undefined,
() => {
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/csharp-SystemTextJson/Issue1520.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace QuickType
{
// Simulates partial helper declarations from another generated file.
public static partial class Serialize { }
internal static partial class Converter { }
}
6 changes: 6 additions & 0 deletions test/fixtures/csharp/Issue1520.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace QuickType
{
// Simulates partial helper declarations from another generated file.
public static partial class Serialize { }
internal static partial class Converter { }
}
35 changes: 35 additions & 0 deletions test/unit/csharp-partial-helpers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { describe, expect, test } from "vitest";

import {
InputData,
type RendererOptions,
jsonInputForTargetLanguage,
quicktype,
} from "quicktype-core";

async function cSharpFor(framework: string): Promise<string> {
const jsonInput = jsonInputForTargetLanguage("csharp");
await jsonInput.addSource({
name: "Something",
samples: ['{"some_property":"hello"}'],
});
const inputData = new InputData();
inputData.addInput(jsonInput);
const rendererOptions = { framework } as RendererOptions;
const result = await quicktype({
inputData,
lang: "csharp",
rendererOptions,
});
return result.lines.join("\n");
}

describe("C# helper classes", () => {
for (const framework of ["NewtonSoft", "SystemTextJson"]) {
test(`${framework} helpers are partial`, async () => {
const output = await cSharpFor(framework);
expect(output).toContain("public static partial class Serialize");
expect(output).toContain("internal static partial class Converter");
});
}
});
Loading