Adopt http\type\dictionary from cadl ranch (#4246)
Fixes: https://github.com/microsoft/typespec/issues/3993 --------- Co-authored-by: ShivangiReja <shivangi.reja@microsoft.com>
This commit is contained in:
Родитель
15be039d0c
Коммит
23d00156cf
|
@ -71,7 +71,6 @@ $failingSpecs = @(
|
|||
Join-Path 'http' 'server' 'versions' 'versioned'
|
||||
Join-Path 'http' 'special-headers' 'conditional-request'
|
||||
Join-Path 'http' 'special-headers' 'repeatability'
|
||||
Join-Path 'http' 'type' 'dictionary'
|
||||
Join-Path 'http' 'type' 'model' 'flatten'
|
||||
Join-Path 'http' 'type' 'model' 'visibility'
|
||||
Join-Path 'http' 'type' 'model' 'inheritance' 'enum-discriminator'
|
||||
|
|
|
@ -210,7 +210,7 @@ namespace Microsoft.Generator.CSharp.ClientModel.Providers
|
|||
{
|
||||
writer.WritePropertyName(item.Property("Key")),
|
||||
new IfElseStatement(
|
||||
item.Property("Value").InvokeEquals(Null),
|
||||
item.Property("Value").Equal(Null),
|
||||
writer.WriteNullValue(),
|
||||
writer.WriteBinaryData(item.Property("Value")))
|
||||
},
|
||||
|
|
|
@ -126,6 +126,11 @@ namespace Microsoft.Generator.CSharp.ClientModel.Providers
|
|||
statements.Add(UsingDeclare("content", BinaryContentHelperSnippets.FromEnumerable(parameter), out var content));
|
||||
declarations["content"] = content;
|
||||
}
|
||||
else if (parameter.Type.IsDictionary)
|
||||
{
|
||||
statements.Add(UsingDeclare("content", BinaryContentHelperSnippets.FromDictionary(parameter), out var content));
|
||||
declarations["content"] = content;
|
||||
}
|
||||
else if (parameter.Type.Equals(typeof(string)))
|
||||
{
|
||||
var bdExpression = Operation.RequestMediaTypes?.Contains("application/json") == true
|
||||
|
@ -210,30 +215,62 @@ namespace Microsoft.Generator.CSharp.ClientModel.Providers
|
|||
return statements;
|
||||
}
|
||||
}
|
||||
else if (responseBodyType.IsDictionary)
|
||||
{
|
||||
var keyType = responseBodyType.Arguments[0];
|
||||
var valueType = responseBodyType.Arguments[1];
|
||||
if (!valueType.IsFrameworkType || valueType.Equals(typeof(TimeSpan)) || valueType.Equals(typeof(BinaryData)))
|
||||
{
|
||||
var valueDeclaration = Declare("value", New.Instance(new CSharpType(typeof(Dictionary<,>), keyType, valueType)).As(responseBodyType), out var value);
|
||||
MethodBodyStatement[] statements =
|
||||
[
|
||||
valueDeclaration,
|
||||
UsingDeclare("document", JsonDocumentSnippets.Parse(result.GetRawResponse().ContentStream(), isAsync), out var document),
|
||||
ForeachStatement.Create("item", document.RootElement().EnumerateObject(), out ScopedApi<JsonProperty> item)
|
||||
.Add(GetElementConversion(valueType, item.Value(), value, item.Name()))
|
||||
];
|
||||
declarations = new Dictionary<string, ValueExpression>
|
||||
{
|
||||
{ "value", value }
|
||||
};
|
||||
return statements;
|
||||
}
|
||||
}
|
||||
|
||||
declarations = [];
|
||||
return [];
|
||||
}
|
||||
|
||||
private MethodBodyStatement GetElementConversion(CSharpType elementType, ScopedApi<JsonElement> item, ScopedApi value)
|
||||
private MethodBodyStatement GetElementConversion(CSharpType elementType, ScopedApi<JsonElement> item, ScopedApi value, ValueExpression? dictKey = null)
|
||||
{
|
||||
if (elementType.Equals(typeof(TimeSpan)))
|
||||
{
|
||||
return value.Add(item.Invoke("GetTimeSpan", Literal("P")));
|
||||
return AddElement(dictKey, item.Invoke("GetTimeSpan", Literal("P")), value);
|
||||
}
|
||||
else if (elementType.Equals(typeof(BinaryData)))
|
||||
{
|
||||
return new IfElseStatement(
|
||||
item.ValueKind().Equal(JsonValueKindSnippets.Null),
|
||||
value.Add(Null),
|
||||
value.Add(BinaryDataSnippets.FromString(item.GetRawText())));
|
||||
AddElement(dictKey, Null, value),
|
||||
AddElement(dictKey, BinaryDataSnippets.FromString(item.GetRawText()), value));
|
||||
}
|
||||
else
|
||||
{
|
||||
return value.Add(Static(elementType).Invoke($"Deserialize{elementType.Name}", item, ModelSerializationExtensionsSnippets.Wire));
|
||||
return AddElement(dictKey, Static(elementType).Invoke($"Deserialize{elementType.Name}", item, ModelSerializationExtensionsSnippets.Wire), value);
|
||||
}
|
||||
}
|
||||
|
||||
private MethodBodyStatement AddElement(ValueExpression? dictKey, ValueExpression element, ScopedApi scopedApi)
|
||||
{
|
||||
if (dictKey != null)
|
||||
{
|
||||
// Add items to dictionary
|
||||
return scopedApi.Add(dictKey, element);
|
||||
}
|
||||
// Add items to list
|
||||
return scopedApi.Add(element);
|
||||
}
|
||||
|
||||
private ValueExpression GetResultConversion(ScopedApi<ClientResult> result, CSharpType responseBodyType, Dictionary<string, ValueExpression> declarations)
|
||||
{
|
||||
if (responseBodyType.Equals(typeof(BinaryData)))
|
||||
|
@ -251,6 +288,17 @@ namespace Microsoft.Generator.CSharp.ClientModel.Providers
|
|||
return result.GetRawResponse().Content().ToObjectFromJson(responseBodyType);
|
||||
}
|
||||
}
|
||||
if (responseBodyType.IsDictionary)
|
||||
{
|
||||
if (!responseBodyType.Arguments[1].IsFrameworkType || responseBodyType.Arguments[1].Equals(typeof(TimeSpan)) || responseBodyType.Arguments[1].Equals(typeof(BinaryData)))
|
||||
{
|
||||
return declarations["value"];
|
||||
}
|
||||
else
|
||||
{
|
||||
return result.GetRawResponse().Content().ToObjectFromJson(responseBodyType);
|
||||
}
|
||||
}
|
||||
if (responseBodyType.Equals(typeof(string)) && Operation.RequestMediaTypes?.Contains("text/plain") == true)
|
||||
{
|
||||
return result.GetRawResponse().Content().InvokeToString();
|
||||
|
|
|
@ -14,6 +14,9 @@ namespace Microsoft.Generator.CSharp.ClientModel.Snippets
|
|||
public static ScopedApi<BinaryContent> FromEnumerable(ValueExpression body)
|
||||
=> Static<BinaryContentHelperDefinition>().Invoke("FromEnumerable", body).As<BinaryContent>();
|
||||
|
||||
public static ScopedApi<BinaryContent> FromDictionary(ValueExpression body)
|
||||
=> Static<BinaryContentHelperDefinition>().Invoke("FromDictionary", body).As<BinaryContent>();
|
||||
|
||||
public static ScopedApi<BinaryContent> FromReadOnlyMemory(ValueExpression body)
|
||||
=> Static<BinaryContentHelperDefinition>().Invoke("FromReadOnlyMemory", body).As<BinaryContent>();
|
||||
|
||||
|
|
|
@ -65,6 +65,11 @@
|
|||
"commandName": "Executable",
|
||||
"executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe"
|
||||
},
|
||||
"http-type-dictionary": {
|
||||
"commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/type/dictionary -p StubLibraryPlugin",
|
||||
"commandName": "Executable",
|
||||
"executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe"
|
||||
},
|
||||
"http-type-enum-extensible": {
|
||||
"commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/type/enum/extensible -p StubLibraryPlugin",
|
||||
"commandName": "Executable",
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Generator.CSharp.Expressions;
|
||||
using Microsoft.Generator.CSharp.Statements;
|
||||
|
||||
namespace Microsoft.Generator.CSharp.Snippets
|
||||
{
|
||||
public static class DictionarySnippets
|
||||
{
|
||||
public static MethodBodyStatement Add(this ScopedApi dictionaryExpression, ValueExpression key, ValueExpression value)
|
||||
=> CheckForDictionary(dictionaryExpression).Invoke(nameof(Dictionary<object, object>.Add), key, value).Terminate();
|
||||
|
||||
private static ScopedApi CheckForDictionary(ScopedApi dictionaryExpression)
|
||||
{
|
||||
if (!dictionaryExpression.Type.IsDictionary)
|
||||
{
|
||||
throw new InvalidOperationException("The provided expression is not a Dictionary.");
|
||||
}
|
||||
return dictionaryExpression;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using _Type.Dictionary;
|
||||
using _Type.Dictionary.Models;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace TestProjects.CadlRanch.Tests.Http._Type.Dictionary
|
||||
{
|
||||
public class DictionaryTests : CadlRanchTestBase
|
||||
{
|
||||
[CadlRanchTest]
|
||||
public Task Int32ValueGet() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetInt32ValueClient().GetAsync();
|
||||
Assert.AreEqual(2, response.Value.Count);
|
||||
Assert.AreEqual(1, response.Value["k1"]);
|
||||
Assert.AreEqual(2, response.Value["k2"]);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task Int32ValuePut() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetInt32ValueClient().PutAsync(new Dictionary<string, int>()
|
||||
{
|
||||
{"k1", 1 },
|
||||
{"k2", 2 }
|
||||
});
|
||||
Assert.AreEqual(204, response.GetRawResponse().Status);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task Int64ValueGet() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetInt64ValueClient().GetAsync();
|
||||
Assert.AreEqual(2, response.Value.Count);
|
||||
Assert.AreEqual(9007199254740991, response.Value["k1"]);
|
||||
Assert.AreEqual(-9007199254740991, response.Value["k2"]);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task Int64ValuePut() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetInt64ValueClient().PutAsync(new Dictionary<string, long>()
|
||||
{
|
||||
{"k1", 9007199254740991 },
|
||||
{"k2", -9007199254740991 }
|
||||
});
|
||||
Assert.AreEqual(204, response.GetRawResponse().Status);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task BooleanGet() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetBooleanValueClient().GetAsync();
|
||||
Assert.AreEqual(2, response.Value.Count);
|
||||
Assert.AreEqual(true, response.Value["k1"]);
|
||||
Assert.AreEqual(false, response.Value["k2"]);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task BooleanPut() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetBooleanValueClient().PutAsync(new Dictionary<string, bool>()
|
||||
{
|
||||
{"k1", true },
|
||||
{"k2", false }
|
||||
});
|
||||
Assert.AreEqual(204, response.GetRawResponse().Status);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task StringGet() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetStringValueClient().GetAsync();
|
||||
Assert.AreEqual(2, response.Value.Count);
|
||||
Assert.AreEqual("hello", response.Value["k1"]);
|
||||
Assert.AreEqual("", response.Value["k2"]);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task StringPut() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetStringValueClient().PutAsync(new Dictionary<string, string>()
|
||||
{
|
||||
{"k1", "hello" },
|
||||
{"k2", "" }
|
||||
});
|
||||
Assert.AreEqual(204, response.GetRawResponse().Status);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task Float32ValueGet() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetFloat32ValueClient().GetAsync();
|
||||
Assert.AreEqual(1, response.Value.Count);
|
||||
Assert.AreEqual(43.125f, response.Value["k1"]);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task Float32ValuePut() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetFloat32ValueClient().PutAsync(new Dictionary<string, float>()
|
||||
{
|
||||
{"k1", 43.125f }
|
||||
});
|
||||
Assert.AreEqual(204, response.GetRawResponse().Status);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task DatetimeValueGet() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetDatetimeValueClient().GetAsync();
|
||||
Assert.AreEqual(1, response.Value.Count);
|
||||
Assert.AreEqual(DateTimeOffset.Parse("2022-08-26T18:38:00Z"), response.Value["k1"]);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task DatetimeValuePut() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetDatetimeValueClient().PutAsync(new Dictionary<string, DateTimeOffset>()
|
||||
{
|
||||
{"k1", DateTimeOffset.Parse("2022-08-26T18:38:00Z") }
|
||||
});
|
||||
Assert.AreEqual(204, response.GetRawResponse().Status);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task DurationValueGet() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetDurationValueClient().GetAsync();
|
||||
Assert.AreEqual(1, response.Value.Count);
|
||||
Assert.AreEqual(XmlConvert.ToTimeSpan("P123DT22H14M12.011S"), response.Value["k1"]);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task DurationValuePut() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetDurationValueClient().PutAsync(new Dictionary<string, TimeSpan>()
|
||||
{
|
||||
{"k1", XmlConvert.ToTimeSpan("P123DT22H14M12.011S") }
|
||||
});
|
||||
Assert.AreEqual(204, response.GetRawResponse().Status);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task UnknownValueGet() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetUnknownValueClient().GetAsync();
|
||||
Assert.AreEqual(3, response.Value.Count);
|
||||
Assert.AreEqual(1, response.Value["k1"].ToObjectFromJson<int>());
|
||||
Assert.AreEqual("hello", response.Value["k2"].ToObjectFromJson<string>());
|
||||
Assert.AreEqual(null, response.Value["k3"]);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task UnknownValuePut() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetUnknownValueClient().PutAsync(new Dictionary<string, BinaryData?>()
|
||||
{
|
||||
{"k1", new BinaryData(1) },
|
||||
{"k2", new BinaryData("\"hello\"") },
|
||||
{"k3", null }
|
||||
});
|
||||
Assert.AreEqual(204, response.GetRawResponse().Status);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task ModelValueGet() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetModelValueClient().GetAsync();
|
||||
Assert.AreEqual(2, response.Value.Count);
|
||||
Assert.AreEqual("hello", response.Value["k1"].Property);
|
||||
Assert.AreEqual("world", response.Value["k2"].Property);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task ModelValuePut() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetModelValueClient().PutAsync(new Dictionary<string, InnerModel>()
|
||||
{
|
||||
{"k1", new InnerModel("hello") },
|
||||
{"k2", new InnerModel("world") }
|
||||
});
|
||||
Assert.AreEqual(204, response.GetRawResponse().Status);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task RecursiveModelValueGet() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetRecursiveModelValueClient().GetAsync();
|
||||
Assert.AreEqual(2, response.Value.Count);
|
||||
Assert.AreEqual("hello", response.Value["k1"].Property);
|
||||
Assert.AreEqual(0, response.Value["k1"].Children.Count);
|
||||
Assert.AreEqual("world", response.Value["k2"].Property);
|
||||
Assert.AreEqual("inner world", response.Value["k2"].Children["k2.1"].Property);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task RecursiveModelValuePut() => Test(async (host) =>
|
||||
{
|
||||
var firstModel = new InnerModel("hello");
|
||||
firstModel.Children.Clear();
|
||||
var response = await new DictionaryClient(host, null).GetRecursiveModelValueClient().PutAsync(new Dictionary<string, InnerModel>()
|
||||
{
|
||||
["k1"] = firstModel,
|
||||
["k2"] = new InnerModel("world")
|
||||
{
|
||||
Children =
|
||||
{
|
||||
["k2.1"] = new InnerModel("inner world")
|
||||
}
|
||||
}
|
||||
});
|
||||
Assert.AreEqual(204, response.GetRawResponse().Status);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task NullableFloatValueGet() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetNullableFloatValueClient().GetAsync();
|
||||
Assert.AreEqual(3, response.Value.Count);
|
||||
Assert.AreEqual(1.25f, response.Value["k1"]);
|
||||
Assert.AreEqual(0.5f, response.Value["k2"]);
|
||||
Assert.AreEqual(null, response.Value["k3"]);
|
||||
});
|
||||
|
||||
[CadlRanchTest]
|
||||
public Task NullableFloatValuePut() => Test(async (host) =>
|
||||
{
|
||||
var response = await new DictionaryClient(host, null).GetNullableFloatValueClient().PutAsync(new Dictionary<string, float?>()
|
||||
{
|
||||
{"k1", 1.25f },
|
||||
{"k2", 0.5f },
|
||||
{"k3", null }
|
||||
});
|
||||
Assert.AreEqual(204, response.GetRawResponse().Status);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"output-folder": ".",
|
||||
"namespace": "Type.Dictionary",
|
||||
"library-name": "Type.Dictionary",
|
||||
"use-model-reader-writer": true
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29709.97
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_Type.Dictionary", "src\_Type.Dictionary.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,34 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class BooleanValue
|
||||
{
|
||||
protected BooleanValue() => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual ClientResult Get(RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> GetAsync(RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult<IDictionary<string, bool>> Get() => throw null;
|
||||
|
||||
public virtual Task<ClientResult<IDictionary<string, bool>>> GetAsync() => throw null;
|
||||
|
||||
public virtual ClientResult Put(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult Put(IDictionary<string, bool> body) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(IDictionary<string, bool> body) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class DatetimeValue
|
||||
{
|
||||
protected DatetimeValue() => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual ClientResult Get(RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> GetAsync(RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult<IDictionary<string, DateTimeOffset>> Get() => throw null;
|
||||
|
||||
public virtual Task<ClientResult<IDictionary<string, DateTimeOffset>>> GetAsync() => throw null;
|
||||
|
||||
public virtual ClientResult Put(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult Put(IDictionary<string, DateTimeOffset> body) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(IDictionary<string, DateTimeOffset> body) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.ClientModel.Primitives;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class DictionaryClient
|
||||
{
|
||||
public DictionaryClient() : this(new Uri("http://localhost:3000"), new DictionaryClientOptions()) => throw null;
|
||||
|
||||
public DictionaryClient(Uri endpoint, DictionaryClientOptions options) => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual Int32Value GetInt32ValueClient() => throw null;
|
||||
|
||||
public virtual Int64Value GetInt64ValueClient() => throw null;
|
||||
|
||||
public virtual BooleanValue GetBooleanValueClient() => throw null;
|
||||
|
||||
public virtual StringValue GetStringValueClient() => throw null;
|
||||
|
||||
public virtual Float32Value GetFloat32ValueClient() => throw null;
|
||||
|
||||
public virtual DatetimeValue GetDatetimeValueClient() => throw null;
|
||||
|
||||
public virtual DurationValue GetDurationValueClient() => throw null;
|
||||
|
||||
public virtual UnknownValue GetUnknownValueClient() => throw null;
|
||||
|
||||
public virtual ModelValue GetModelValueClient() => throw null;
|
||||
|
||||
public virtual RecursiveModelValue GetRecursiveModelValueClient() => throw null;
|
||||
|
||||
public virtual NullableFloatValue GetNullableFloatValueClient() => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.ClientModel.Primitives;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class DictionaryClientOptions : ClientPipelineOptions
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class DurationValue
|
||||
{
|
||||
protected DurationValue() => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual ClientResult Get(RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> GetAsync(RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult<IDictionary<string, TimeSpan>> Get() => throw null;
|
||||
|
||||
public virtual Task<ClientResult<IDictionary<string, TimeSpan>>> GetAsync() => throw null;
|
||||
|
||||
public virtual ClientResult Put(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult Put(IDictionary<string, TimeSpan> body) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(IDictionary<string, TimeSpan> body) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class Float32Value
|
||||
{
|
||||
protected Float32Value() => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual ClientResult Get(RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> GetAsync(RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult<IDictionary<string, float>> Get() => throw null;
|
||||
|
||||
public virtual Task<ClientResult<IDictionary<string, float>>> GetAsync() => throw null;
|
||||
|
||||
public virtual ClientResult Put(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult Put(IDictionary<string, float> body) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(IDictionary<string, float> body) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class Int32Value
|
||||
{
|
||||
protected Int32Value() => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual ClientResult Get(RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> GetAsync(RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult<IDictionary<string, int>> Get() => throw null;
|
||||
|
||||
public virtual Task<ClientResult<IDictionary<string, int>>> GetAsync() => throw null;
|
||||
|
||||
public virtual ClientResult Put(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult Put(IDictionary<string, int> body) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(IDictionary<string, int> body) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class Int64Value
|
||||
{
|
||||
protected Int64Value() => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual ClientResult Get(RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> GetAsync(RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult<IDictionary<string, long>> Get() => throw null;
|
||||
|
||||
public virtual Task<ClientResult<IDictionary<string, long>>> GetAsync() => throw null;
|
||||
|
||||
public virtual ClientResult Put(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult Put(IDictionary<string, long> body) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(IDictionary<string, long> body) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _Type.Dictionary.Models;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class ModelValue
|
||||
{
|
||||
protected ModelValue() => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual ClientResult Get(RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> GetAsync(RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult<IDictionary<string, InnerModel>> Get() => throw null;
|
||||
|
||||
public virtual Task<ClientResult<IDictionary<string, InnerModel>>> GetAsync() => throw null;
|
||||
|
||||
public virtual ClientResult Put(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult Put(IDictionary<string, InnerModel> body) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(IDictionary<string, InnerModel> body) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace _Type.Dictionary.Models
|
||||
{
|
||||
public partial class InnerModel : IJsonModel<InnerModel>
|
||||
{
|
||||
void IJsonModel<InnerModel>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null;
|
||||
|
||||
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null;
|
||||
|
||||
InnerModel IJsonModel<InnerModel>.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null;
|
||||
|
||||
protected virtual InnerModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null;
|
||||
|
||||
BinaryData IPersistableModel<InnerModel>.Write(ModelReaderWriterOptions options) => throw null;
|
||||
|
||||
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null;
|
||||
|
||||
InnerModel IPersistableModel<InnerModel>.Create(BinaryData data, ModelReaderWriterOptions options) => throw null;
|
||||
|
||||
protected virtual InnerModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null;
|
||||
|
||||
string IPersistableModel<InnerModel>.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null;
|
||||
|
||||
public static implicit operator BinaryContent(InnerModel innerModel) => throw null;
|
||||
|
||||
public static explicit operator InnerModel(ClientResult result) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace _Type.Dictionary.Models
|
||||
{
|
||||
public partial class InnerModel
|
||||
{
|
||||
public InnerModel(string @property) => throw null;
|
||||
|
||||
public string Property
|
||||
{
|
||||
get => throw null;
|
||||
set => throw null;
|
||||
}
|
||||
|
||||
|
||||
public IDictionary<string, InnerModel> Children => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class NullableFloatValue
|
||||
{
|
||||
protected NullableFloatValue() => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual ClientResult Get(RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> GetAsync(RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult<IDictionary<string, float?>> Get() => throw null;
|
||||
|
||||
public virtual Task<ClientResult<IDictionary<string, float?>>> GetAsync() => throw null;
|
||||
|
||||
public virtual ClientResult Put(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult Put(IDictionary<string, float?> body) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(IDictionary<string, float?> body) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _Type.Dictionary.Models;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class RecursiveModelValue
|
||||
{
|
||||
protected RecursiveModelValue() => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual ClientResult Get(RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> GetAsync(RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult<IDictionary<string, InnerModel>> Get() => throw null;
|
||||
|
||||
public virtual Task<ClientResult<IDictionary<string, InnerModel>>> GetAsync() => throw null;
|
||||
|
||||
public virtual ClientResult Put(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult Put(IDictionary<string, InnerModel> body) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(IDictionary<string, InnerModel> body) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class StringValue
|
||||
{
|
||||
protected StringValue() => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual ClientResult Get(RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> GetAsync(RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult<IDictionary<string, string>> Get() => throw null;
|
||||
|
||||
public virtual Task<ClientResult<IDictionary<string, string>>> GetAsync() => throw null;
|
||||
|
||||
public virtual ClientResult Put(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult Put(IDictionary<string, string> body) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(IDictionary<string, string> body) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace _Type.Dictionary.Models
|
||||
{
|
||||
public static partial class TypeDictionaryModelFactory
|
||||
{
|
||||
public static InnerModel InnerModel(string @property = default, IDictionary<string, InnerModel> children = default) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// <auto-generated/>
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.ClientModel;
|
||||
using System.ClientModel.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _Type.Dictionary
|
||||
{
|
||||
public partial class UnknownValue
|
||||
{
|
||||
protected UnknownValue() => throw null;
|
||||
|
||||
public ClientPipeline Pipeline => throw null;
|
||||
|
||||
public virtual ClientResult Get(RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> GetAsync(RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult<IDictionary<string, BinaryData>> Get() => throw null;
|
||||
|
||||
public virtual Task<ClientResult<IDictionary<string, BinaryData>>> GetAsync() => throw null;
|
||||
|
||||
public virtual ClientResult Put(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(BinaryContent content, RequestOptions options) => throw null;
|
||||
|
||||
public virtual ClientResult Put(IDictionary<string, BinaryData> body) => throw null;
|
||||
|
||||
public virtual Task<ClientResult> PutAsync(IDictionary<string, BinaryData> body) => throw null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Description>This is the _Type.Dictionary client library for developing .NET applications with rich experience.</Description>
|
||||
<AssemblyTitle>SDK Code Generation _Type.Dictionary</AssemblyTitle>
|
||||
<Version>1.0.0-beta.1</Version>
|
||||
<PackageTags>_Type.Dictionary</PackageTags>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.ClientModel" Version="1.1.0-beta.4" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.4" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -89,7 +89,7 @@ namespace UnbrandedTypeSpec
|
|||
foreach (var item in dictionary)
|
||||
{
|
||||
content.JsonWriter.WritePropertyName(item.Key);
|
||||
if (item.Value.Equals(null))
|
||||
if (item.Value == null)
|
||||
{
|
||||
content.JsonWriter.WriteNullValue();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче