Use reserved namespace "QuickType" in C# to avoid the conflict between the top-level type and namespace name.

This commit is contained in:
David Siegel 2017-09-13 12:33:40 -07:00
Родитель 1da6805c05
Коммит b96ba31e49
3 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -19,7 +19,7 @@ import IRGraph (IRClassData(..), IRType(..), IRUnionRep, Named, forUnion_, isUni
import Options (Option, booleanOption, enumOption)
forbiddenNames :: Array String
forbiddenNames = ["Converter", "JsonConverter", "Type", "Serialize"]
forbiddenNames = ["QuickType", "Converter", "JsonConverter", "Type", "Serialize"]
listOption :: Option Boolean
listOption = enumOption "array-type" "Select C# type to use for JSON arrays" [Tuple "array" false, Tuple "list" true]
@ -119,7 +119,7 @@ csharpDoc = do
oneOfThese <- getForSingleOrMultipleTopLevels "" " one of these"
line $ "// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do" <> oneOfThese <> ":"
line "//"
line $ "// using " <> module_ <> ";"
line $ "// using QuickType;"
forEachTopLevel_ \topLevelName topLevelType -> do
line "//"
line $ "// var data = " <> module_ <> ".FromJson(jsonString);"
@ -127,7 +127,7 @@ csharpDoc = do
line "// For POCOs visit quicktype.io?poco"
line "//"
line $ "namespace " <> module_
line "namespace QuickType"
line "{"
indent do
let using s = line $ "using " <> s <> ";"

2
test/fixtures/csharp/Program.cs поставляемый
Просмотреть файл

@ -8,7 +8,7 @@ namespace QuickType
{
var path = args[0];
var json = System.IO.File.ReadAllText(path);
var output = QuickType.FromJson(json).ToJson();
var output = TopLevel.FromJson(json).ToJson();
Console.WriteLine("{0}", output);
}
}

Просмотреть файл

@ -231,7 +231,7 @@ class CSharpJSONFixture extends JSONFixture {
setupCommand = "dotnet restore --no-cache";
diffViaSchema = true;
output = "QuickType.cs";
topLevel = "QuickType";
topLevel = "TopLevel";
async test(sample: string) {
compareJsonFileToJson({