From 854024a2c6473f0065c86427ba767ed511e94645 Mon Sep 17 00:00:00 2001 From: Crystal YU Date: Tue, 8 Oct 2024 13:30:21 +0800 Subject: [PATCH 01/13] onboard Sever/Path/Single (#4564) Fix https://github.com/microsoft/typespec/issues/3987 --- .../eng/scripts/Generate.ps1 | 1 - .../src/Properties/launchSettings.json | 5 ++ .../Http/Server/Path/Single/SingleTests.cs | 19 +++++ .../server/path/single/Configuration.json | 6 ++ .../server/path/single/Server.Path.Single.sln | 48 ++++++++++++ .../path/single/src/Generated/SingleClient.cs | 30 ++++++++ .../src/Generated/SingleClientOptions.cs | 12 +++ .../path/single/src/Server.Path.Single.csproj | 16 ++++ .../http/server/path/single/tspCodeModel.json | 74 +++++++++++++++++++ 9 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Server/Path/Single/SingleTests.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/Configuration.json create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/Server.Path.Single.sln create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Generated/SingleClient.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Generated/SingleClientOptions.cs create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Server.Path.Single.csproj create mode 100644 packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/tspCodeModel.json diff --git a/packages/http-client-csharp/eng/scripts/Generate.ps1 b/packages/http-client-csharp/eng/scripts/Generate.ps1 index b9ce7d7d76..de0bd2347f 100644 --- a/packages/http-client-csharp/eng/scripts/Generate.ps1 +++ b/packages/http-client-csharp/eng/scripts/Generate.ps1 @@ -65,7 +65,6 @@ $failingSpecs = @( Join-Path 'http' 'serialization' 'encoded-name' 'json' Join-Path 'http' 'server' 'endpoint' 'not-defined' Join-Path 'http' 'server' 'path' 'multiple' - Join-Path 'http' 'server' 'path' 'single' Join-Path 'http' 'server' 'versions' 'versioned' Join-Path 'http' 'special-headers' 'conditional-request' Join-Path 'http' 'special-headers' 'repeatability' diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Properties/launchSettings.json b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Properties/launchSettings.json index 116b6fc680..cc6da7a4c7 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Properties/launchSettings.json +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Properties/launchSettings.json @@ -75,6 +75,11 @@ "commandName": "Executable", "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" }, + "http-server-path-single": { + "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/server/path/single -p StubLibraryPlugin", + "commandName": "Executable", + "executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe" + }, "http-server-versions-not-versioned": { "commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/server/versions/not-versioned -p StubLibraryPlugin", "commandName": "Executable", diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Server/Path/Single/SingleTests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Server/Path/Single/SingleTests.cs new file mode 100644 index 0000000000..e319ad76b1 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Server/Path/Single/SingleTests.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using NUnit.Framework; +using Server.Path.Single; +using System.Threading.Tasks; + +namespace TestProjects.CadlRanch.Tests.Http.Server.Path.Single +{ + public class SingleTests : CadlRanchTestBase + { + [CadlRanchTest] + public Task MyOp() => Test(async (host) => + { + var result = await new SingleClient(host, null).MyOpAsync(); + Assert.AreEqual(200, result.GetRawResponse().Status); + }); + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/Configuration.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/Configuration.json new file mode 100644 index 0000000000..3cfce5d1da --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/Configuration.json @@ -0,0 +1,6 @@ +{ + "output-folder": ".", + "namespace": "Server.Path.Single", + "library-name": "Server.Path.Single", + "use-model-reader-writer": true +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/Server.Path.Single.sln b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/Server.Path.Single.sln new file mode 100644 index 0000000000..b69f06d4c9 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/Server.Path.Single.sln @@ -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}") = "Server.Path.Single", "src\Server.Path.Single.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 diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Generated/SingleClient.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Generated/SingleClient.cs new file mode 100644 index 0000000000..20a681592f --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Generated/SingleClient.cs @@ -0,0 +1,30 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading.Tasks; + +namespace Server.Path.Single +{ + public partial class SingleClient + { + protected SingleClient() => throw null; + + public SingleClient(Uri endpoint) : this(endpoint, new SingleClientOptions()) => throw null; + + public SingleClient(Uri endpoint, SingleClientOptions options) => throw null; + + public ClientPipeline Pipeline => throw null; + + public virtual ClientResult MyOp(RequestOptions options) => throw null; + + public virtual Task MyOpAsync(RequestOptions options) => throw null; + + public virtual ClientResult MyOp() => throw null; + + public virtual Task MyOpAsync() => throw null; + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Generated/SingleClientOptions.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Generated/SingleClientOptions.cs new file mode 100644 index 0000000000..2bf92e1e4d --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Generated/SingleClientOptions.cs @@ -0,0 +1,12 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; + +namespace Server.Path.Single +{ + public partial class SingleClientOptions : ClientPipelineOptions + { + } +} diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Server.Path.Single.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Server.Path.Single.csproj new file mode 100644 index 0000000000..9fb8e6a5ea --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Server.Path.Single.csproj @@ -0,0 +1,16 @@ + + + This is the Server.Path.Single client library for developing .NET applications with rich experience. + SDK Code Generation Server.Path.Single + 1.0.0-beta.1 + Server.Path.Single + netstandard2.0 + latest + true + + + + + + + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/tspCodeModel.json new file mode 100644 index 0000000000..fce25309b2 --- /dev/null +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/tspCodeModel.json @@ -0,0 +1,74 @@ +{ + "$id": "1", + "Name": "Server.Path.Single", + "ApiVersions": [], + "Enums": [], + "Models": [], + "Clients": [ + { + "$id": "2", + "Name": "SingleClient", + "Description": "Illustrates server with a single path parameter @server", + "Operations": [ + { + "$id": "3", + "Name": "myOp", + "ResourceName": "Single", + "Accessibility": "public", + "Parameters": [ + { + "$id": "4", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Description": "Need to be set as 'http://localhost:3000' in client.", + "Type": { + "$id": "5", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + } + ], + "Responses": [ + { + "$id": "6", + "StatusCodes": [ + 200 + ], + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false + } + ], + "HttpMethod": "HEAD", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/server/path/single/myOp", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "Server.Path.Single.myOp", + "Decorators": [] + } + ], + "Protocol": { + "$id": "7" + }, + "Parameters": [ + { + "$ref": "4" + } + ], + "Decorators": [] + } + ] +} From 7aee12fa439e83c544c932b196e2daaebc151ae9 Mon Sep 17 00:00:00 2001 From: Jorge Rangel <102122018+jorgerangel-msft@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:15:39 -0500 Subject: [PATCH 02/13] Remove virtual keyword from struct serial methods & Return Default For Null Elements (#4630) This PR fixes several issues with generated structs: - The `protected virtual` modifiers were removed from the serialization core methods as the modifiers are not valid for structs. - When deserializing the struct, `default` is returned rather than `null` when encountering an JsonElement that is Null. fixes: https://github.com/microsoft/typespec/issues/4348, https://github.com/microsoft/typespec/issues/4349 --- .../MrwSerializationTypeDefinition.cs | 25 +++-- .../DeserializationTests.cs | 50 +++++++++ .../MrwSerializationTypeDefinitionTests.cs | 102 +++++++++++++----- .../DeserializationTests/DeserializeStruct.cs | 44 ++++++++ 4 files changed, 187 insertions(+), 34 deletions(-) create mode 100644 packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/DeserializationTests.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/DeserializationTests/DeserializeStruct.cs diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs index c67842c302..7399051b5e 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs @@ -72,7 +72,7 @@ public MrwSerializationTypeDefinition(InputModelType inputModel, ModelProvider m _rawDataField = _model.Fields.FirstOrDefault(f => f.Name == AdditionalPropertiesHelper.AdditionalBinaryDataPropsFieldName); _additionalBinaryDataProperty = GetAdditionalBinaryDataPropertiesProp(); _additionalProperties = new([.. _model.Properties.Where(p => p.IsAdditionalProperties)]); - _shouldOverrideMethods = _model.Type.BaseType != null && _model.Type.BaseType is { IsFrameworkType: false }; + _shouldOverrideMethods = _model.Type.BaseType != null && !_isStruct && _model.Type.BaseType is { IsFrameworkType: false }; _utf8JsonWriterSnippet = _utf8JsonWriterParameter.As(); _mrwOptionsParameterSnippet = _serializationOptionsParameter.As(); _jsonElementParameterSnippet = _jsonElementDeserializationParam.As(); @@ -304,7 +304,9 @@ internal MethodProvider BuildPersistableModelCreateMethodObjectDeclaration() /// internal MethodProvider BuildJsonModelWriteCoreMethod() { - MethodSignatureModifiers modifiers = MethodSignatureModifiers.Protected | MethodSignatureModifiers.Virtual; + MethodSignatureModifiers modifiers = _isStruct + ? MethodSignatureModifiers.Private + : MethodSignatureModifiers.Protected | MethodSignatureModifiers.Virtual; if (_shouldOverrideMethods) { modifiers = MethodSignatureModifiers.Protected | MethodSignatureModifiers.Override; @@ -323,7 +325,10 @@ internal MethodProvider BuildJsonModelWriteCoreMethod() /// internal MethodProvider BuildPersistableModelWriteCoreMethod() { - MethodSignatureModifiers modifiers = MethodSignatureModifiers.Protected | MethodSignatureModifiers.Virtual; + MethodSignatureModifiers modifiers = _isStruct + ? MethodSignatureModifiers.Private + : MethodSignatureModifiers.Protected | MethodSignatureModifiers.Virtual; + if (_shouldOverrideMethods) { modifiers = MethodSignatureModifiers.Protected | MethodSignatureModifiers.Override; @@ -344,7 +349,10 @@ internal MethodProvider BuildPersistableModelWriteCoreMethod() /// internal MethodProvider BuildPersistableModelCreateCoreMethod() { - MethodSignatureModifiers modifiers = MethodSignatureModifiers.Protected | MethodSignatureModifiers.Virtual; + MethodSignatureModifiers modifiers = _isStruct + ? MethodSignatureModifiers.Private + : MethodSignatureModifiers.Protected | MethodSignatureModifiers.Virtual; + if (_shouldOverrideMethods) { modifiers = MethodSignatureModifiers.Protected | MethodSignatureModifiers.Override; @@ -378,7 +386,10 @@ internal MethodProvider BuildJsonModelCreateMethod() /// internal MethodProvider BuildJsonModelCreateCoreMethod() { - MethodSignatureModifiers modifiers = MethodSignatureModifiers.Protected | MethodSignatureModifiers.Virtual; + MethodSignatureModifiers modifiers = _isStruct + ? MethodSignatureModifiers.Private + : MethodSignatureModifiers.Protected | MethodSignatureModifiers.Virtual; + if (_shouldOverrideMethods) { modifiers = MethodSignatureModifiers.Protected | MethodSignatureModifiers.Override; @@ -545,9 +556,11 @@ private MethodBodyStatement[] BuildDeserializationMethodBody() BuildDeserializePropertiesStatements(prop.As()) }; + var valueKindEqualsNullReturn = _isStruct ? Return(Default) : Return(Null); + return [ - new IfStatement(_jsonElementParameterSnippet.ValueKindEqualsNull()) { Return(Null) }, + new IfStatement(_jsonElementParameterSnippet.ValueKindEqualsNull()) { valueKindEqualsNullReturn }, GetPropertyVariableDeclarations(), deserializePropertiesForEachStatement, Return(New.Instance(_model.Type, GetSerializationCtorParameterValues())) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/DeserializationTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/DeserializationTests.cs new file mode 100644 index 0000000000..9153ab2c9f --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/DeserializationTests.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Linq; +using Microsoft.Generator.CSharp.ClientModel.Providers; +using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Primitives; +using Microsoft.Generator.CSharp.Providers; +using Microsoft.Generator.CSharp.Tests.Common; +using NUnit.Framework; + +namespace Microsoft.Generator.CSharp.ClientModel.Tests.Providers.MrwSerializationTypeDefinitions +{ + public class DeserializationTests + { + public DeserializationTests() + { + MockHelpers.LoadMockPlugin(createSerializationsCore: (inputType, typeProvider) + => inputType is InputModelType modeltype ? [new MockMrwProvider(modeltype, (typeProvider as ModelProvider)!)] : []); + } + + private class MockMrwProvider : MrwSerializationTypeDefinition + { + public MockMrwProvider(InputModelType inputModel, ModelProvider modelProvider) + : base(inputModel, modelProvider) + { + } + + protected override MethodProvider[] BuildMethods() + { + return [.. base.BuildMethods().Where(m => m.Signature.Name.StartsWith("Deserialize"))]; + } + + protected override FieldProvider[] BuildFields() => []; + protected override ConstructorProvider[] BuildConstructors() => []; + } + + [Test] + public void DeserializeStruct() + { + var inputModel = InputFactory.Model("TestModel", modelAsStruct: true); + + var mrwProvider = new ModelProvider(inputModel).SerializationProviders.FirstOrDefault(); + Assert.IsNotNull(mrwProvider); + var writer = new TypeProviderWriter(mrwProvider!); + var file = writer.Write(); + Assert.AreEqual(Helpers.GetExpectedFromFile(), file.Content); + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs index 744283ab88..126c6e3f52 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/MrwSerializationTypeDefinitionTests.cs @@ -57,10 +57,11 @@ public void TestBuildImplements() } // This test validates the json model serialization write method is built correctly - [Test] - public void TestBuildJsonModelWriteCoreMethod() + [TestCase(true)] + [TestCase(false)] + public void TestBuildJsonModelWriteCoreMethod(bool isStruct) { - var inputModel = InputFactory.Model("mockInputModel"); + var inputModel = InputFactory.Model("mockInputModel", modelAsStruct: isStruct); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelWriteCoreMethod(); @@ -74,17 +75,25 @@ public void TestBuildJsonModelWriteCoreMethod() Assert.IsNull(methodSignature?.ReturnType); // Check method modifiers - var expectedModifiers = MethodSignatureModifiers.Protected; - if (model.Type.BaseType != null) + MethodSignatureModifiers expectedModifiers; + if (isStruct) { - expectedModifiers |= MethodSignatureModifiers.Override; + expectedModifiers = MethodSignatureModifiers.Private; } else { - expectedModifiers |= MethodSignatureModifiers.Virtual; + expectedModifiers = MethodSignatureModifiers.Protected; + if (model.Type.BaseType != null) + { + expectedModifiers |= MethodSignatureModifiers.Override; + } + else + { + expectedModifiers |= MethodSignatureModifiers.Virtual; + } } - Assert.AreEqual(expectedModifiers, methodSignature?.Modifiers, "Method modifiers do not match the expected value."); + Assert.AreEqual(expectedModifiers, methodSignature?.Modifiers, "Method modifiers do not match the expected value."); // Validate body var methodBody = method?.BodyStatements; @@ -146,10 +155,11 @@ public void TestBuildJsonModelCreateMethod() } // This test validates the json model serialization create core method is built correctly - [Test] - public void TestBuildJsonModelCreateCoreMethod() + [TestCase(true)] + [TestCase(false)] + public void TestBuildJsonModelCreateCoreMethod(bool isStruct) { - var inputModel = InputFactory.Model("mockInputModel"); + var inputModel = InputFactory.Model("mockInputModel", modelAsStruct: isStruct); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildJsonModelCreateCoreMethod(); @@ -163,17 +173,25 @@ public void TestBuildJsonModelCreateCoreMethod() Assert.AreEqual(model.Type, methodSignature?.ReturnType); // Check method modifiers - var expectedModifiers = MethodSignatureModifiers.Protected; - if (model.Type.BaseType != null) + MethodSignatureModifiers expectedModifiers; + if (isStruct) { - expectedModifiers |= MethodSignatureModifiers.Override; + expectedModifiers = MethodSignatureModifiers.Private; } else { - expectedModifiers |= MethodSignatureModifiers.Virtual; + expectedModifiers = MethodSignatureModifiers.Protected; + if (model.Type.BaseType != null) + { + expectedModifiers |= MethodSignatureModifiers.Override; + } + else + { + expectedModifiers |= MethodSignatureModifiers.Virtual; + } } - Assert.AreEqual(expectedModifiers, methodSignature?.Modifiers, "Method modifiers do not match the expected value."); + Assert.AreEqual(expectedModifiers, methodSignature?.Modifiers, "Method modifiers do not match the expected value."); // Validate body var methodBody = method?.BodyStatements; @@ -236,10 +254,11 @@ public void TestBuildPersistableModelWriteMethod() } // This test validates the persistable model serialization write core method is built correctly - [Test] - public void TestBuildPersistableModelWriteCoreMethod() + [TestCase(true)] + [TestCase(false)] + public void TestBuildPersistableModelWriteCoreMethod(bool isStruct) { - var inputModel = InputFactory.Model("mockInputModel"); + var inputModel = InputFactory.Model("mockInputModel", modelAsStruct: isStruct); var (model, serialization) = CreateModelAndSerialization(inputModel); var method = serialization.BuildPersistableModelWriteCoreMethod(); @@ -253,17 +272,26 @@ public void TestBuildPersistableModelWriteCoreMethod() Assert.AreEqual(new CSharpType(typeof(BinaryData)), methodSignature?.ReturnType); // Check method modifiers - var expectedModifiers = MethodSignatureModifiers.Protected; - if (model.Type.BaseType != null) + // Check method modifiers + MethodSignatureModifiers expectedModifiers; + if (isStruct) { - expectedModifiers |= MethodSignatureModifiers.Override; + expectedModifiers = MethodSignatureModifiers.Private; } else { - expectedModifiers |= MethodSignatureModifiers.Virtual; + expectedModifiers = MethodSignatureModifiers.Protected; + if (model.Type.BaseType != null) + { + expectedModifiers |= MethodSignatureModifiers.Override; + } + else + { + expectedModifiers |= MethodSignatureModifiers.Virtual; + } } - Assert.AreEqual(expectedModifiers, methodSignature?.Modifiers, "Method modifiers do not match the expected value."); + Assert.AreEqual(expectedModifiers, methodSignature?.Modifiers, "Method modifiers do not match the expected value."); // Validate body var methodBody = method?.BodyStatements; @@ -335,10 +363,11 @@ public void TestBuildPersistableModelCreateMethod() } // This test validates the persistable model serialization create core method is built correctly - [Test] - public void TestBuildPersistableModelCreateCoreMethod() + [TestCase(true)] + [TestCase(false)] + public void TestBuildPersistableModelCreateCoreMethod(bool isStruct) { - var inputModel = InputFactory.Model("mockInputModel"); + var inputModel = InputFactory.Model("mockInputModel", modelAsStruct: isStruct); var (model, serialization) = CreateModelAndSerialization(inputModel); Assert.IsNotNull(serialization); @@ -355,7 +384,24 @@ public void TestBuildPersistableModelCreateCoreMethod() Assert.AreEqual(model.Type, methodSignature?.ReturnType); // Check method modifiers - var expectedModifiers = MethodSignatureModifiers.Protected | MethodSignatureModifiers.Virtual; + MethodSignatureModifiers expectedModifiers; + if (isStruct) + { + expectedModifiers = MethodSignatureModifiers.Private; + } + else + { + expectedModifiers = MethodSignatureModifiers.Protected; + if (model.Type.BaseType != null) + { + expectedModifiers |= MethodSignatureModifiers.Override; + } + else + { + expectedModifiers |= MethodSignatureModifiers.Virtual; + } + } + Assert.AreEqual(expectedModifiers, methodSignature?.Modifiers, "Method modifiers do not match the expected value."); // Validate body diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/DeserializationTests/DeserializeStruct.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/DeserializationTests/DeserializeStruct.cs new file mode 100644 index 0000000000..161c68dde7 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/DeserializationTests/DeserializeStruct.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Sample; + +namespace Sample.Models +{ + /// + public readonly partial struct TestModel : global::System.ClientModel.Primitives.IJsonModel, global::System.ClientModel.Primitives.IJsonModel + { + internal static global::Sample.Models.TestModel DeserializeTestModel(global::System.Text.Json.JsonElement element, global::System.ClientModel.Primitives.ModelReaderWriterOptions options) + { + if ((element.ValueKind == global::System.Text.Json.JsonValueKind.Null)) + { + return default; + } + string stringProperty = default; + global::System.Collections.Generic.IDictionary additionalBinaryDataProperties = new global::Sample.ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("stringProperty"u8)) + { + if ((prop.Value.ValueKind == global::System.Text.Json.JsonValueKind.Null)) + { + stringProperty = null; + continue; + } + stringProperty = prop.Value.GetString(); + continue; + } + if ((options.Format != "W")) + { + additionalBinaryDataProperties.Add(prop.Name, global::System.BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new global::Sample.Models.TestModel(stringProperty, additionalBinaryDataProperties); + } + } +} From c78c61468f6728dc085ec9f11d9c4da36cc1ebb0 Mon Sep 17 00:00:00 2001 From: Mingzhe Huang Date: Wed, 9 Oct 2024 15:49:56 +0800 Subject: [PATCH 03/13] refactor(http-client-csharp): do not flatten property in emitter (#4449) Per discussion, we thought we should not flatten properties in emitter, to keep it as simple as possible. The flattening logic should be implemented in generator. part of https://github.com/Azure/autorest.csharp/issues/4788 --------- Co-authored-by: Mingzhe Huang (from Dev Box) --- .../emitter/src/lib/converter.ts | 93 +++++++------------ .../emitter/src/type/input-type.ts | 2 +- .../src/InputTypes/InputModelProperty.cs | 5 +- .../src/InputTypes/InputModelType.cs | 3 +- .../TypeSpecInputModelPropertyConverter.cs | 8 +- .../test/common/InputFactory.cs | 3 +- .../authentication/api-key/tspCodeModel.json | 1 + .../http/custom/tspCodeModel.json | 1 + .../authentication/oauth2/tspCodeModel.json | 1 + .../http/client/naming/tspCodeModel.json | 5 + .../http/encode/bytes/tspCodeModel.json | 4 + .../http/encode/datetime/tspCodeModel.json | 5 + .../http/encode/duration/tspCodeModel.json | 6 ++ .../http/parameters/basic/tspCodeModel.json | 2 + .../http/parameters/spread/tspCodeModel.json | 11 +++ .../http/payload/multipart/tspCodeModel.json | 31 +++++++ .../http/payload/xml/tspCodeModel.json | 22 +++++ .../http/type/array/tspCodeModel.json | 2 + .../http/type/dictionary/tspCodeModel.json | 2 + .../enum-discriminator/tspCodeModel.json | 6 ++ .../single-discriminator/tspCodeModel.json | 12 +++ .../http/type/model/usage/tspCodeModel.json | 3 + .../additional-properties/tspCodeModel.json | 50 ++++++++++ .../type/property/nullable/tspCodeModel.json | 15 +++ .../property/optionality/tspCodeModel.json | 17 ++++ .../property/value-types/tspCodeModel.json | 29 ++++++ .../http/type/union/tspCodeModel.json | 35 +++++++ .../Unbranded-TypeSpec/tspCodeModel.json | 42 +++++++++ 28 files changed, 345 insertions(+), 71 deletions(-) diff --git a/packages/http-client-csharp/emitter/src/lib/converter.ts b/packages/http-client-csharp/emitter/src/lib/converter.ts index 2b31e70ab9..9e49a27aea 100644 --- a/packages/http-client-csharp/emitter/src/lib/converter.ts +++ b/packages/http-client-csharp/emitter/src/lib/converter.ts @@ -133,24 +133,20 @@ export function fromSdkModelType( ? fromSdkType(modelType.additionalProperties, context, typeMap) : undefined; - const propertiesDict = new Map(); + const propertiesDict = new Map(); for (const property of modelType.properties) { if (property.kind !== "property") { continue; } - const ourProperties = fromSdkModelProperty( - property, - { - ModelName: modelTypeName, - Usage: modelType.usage, - } as LiteralTypeContext, - [], - ); - propertiesDict.set(property, ourProperties); + const ourProperty = fromSdkModelProperty(property, { + ModelName: modelTypeName, + Usage: modelType.usage, + } as LiteralTypeContext); + propertiesDict.set(property, ourProperty); } inputModelType.discriminatorProperty = modelType.discriminatorProperty - ? propertiesDict.get(modelType.discriminatorProperty)![0] + ? propertiesDict.get(modelType.discriminatorProperty) : undefined; inputModelType.baseModel = modelType.baseModel @@ -174,56 +170,37 @@ export function fromSdkModelType( function fromSdkModelProperty( property: SdkBodyModelPropertyType, literalTypeContext: LiteralTypeContext, - flattenedNamePrefixes: string[], - ): InputModelProperty[] { - // TODO -- we should consolidate the flatten somewhere else - if (!property.flatten) { - /* remove this when https://github.com/Azure/typespec-azure/issues/1483 and https://github.com/Azure/typespec-azure/issues/1488 are resolved. */ - let targetType = property.type; - if (targetType.kind === "model") { - const body = targetType.properties.find((x) => x.kind === "body"); - if (body) targetType = body.type; - } - - const serializedName = property.serializedName; - literalTypeContext.PropertyName = serializedName; - - const modelProperty: InputModelProperty = { - kind: property.kind, - name: property.name, - serializedName: serializedName, - description: property.description, - type: fromSdkType( - targetType, - context, - typeMap, - property.discriminator ? undefined : literalTypeContext, // this is a workaround because the type of discriminator property in derived models is always literal and we wrap literal into enums, which leads to a lot of extra enum types, adding this check to avoid them - ), - optional: property.optional, - readOnly: isReadOnly(property), // TODO -- we might pass the visibility through and then check if there is only read to know if this is readonly - discriminator: property.discriminator, - flattenedNames: - flattenedNamePrefixes.length > 0 - ? flattenedNamePrefixes.concat(property.name) - : undefined, - decorators: property.decorators, - crossLanguageDefinitionId: property.crossLanguageDefinitionId, - }; - - return [modelProperty]; + ): InputModelProperty { + /* remove this when https://github.com/Azure/typespec-azure/issues/1483 and https://github.com/Azure/typespec-azure/issues/1488 are resolved. */ + let targetType = property.type; + if (targetType.kind === "model") { + const body = targetType.properties.find((x) => x.kind === "body"); + if (body) targetType = body.type; } - const flattenedProperties: InputModelProperty[] = []; - const childPropertiesToFlatten = (property.type as SdkModelType).properties; - const newFlattenedNamePrefixes = flattenedNamePrefixes.concat(property.serializedName); - for (const childProperty of childPropertiesToFlatten) { - if (childProperty.kind !== "property") continue; - flattenedProperties.push( - ...fromSdkModelProperty(childProperty, literalTypeContext, newFlattenedNamePrefixes), - ); - } + const serializedName = property.serializedName; + literalTypeContext.PropertyName = serializedName; + + const modelProperty: InputModelProperty = { + kind: property.kind, + name: property.name, + serializedName: serializedName, + description: property.description, + type: fromSdkType( + targetType, + context, + typeMap, + property.discriminator ? undefined : literalTypeContext, // this is a workaround because the type of discriminator property in derived models is always literal and we wrap literal into enums, which leads to a lot of extra enum types, adding this check to avoid them + ), + optional: property.optional, + readOnly: isReadOnly(property), // TODO -- we might pass the visibility through and then check if there is only read to know if this is readonly + discriminator: property.discriminator, + flatten: property.flatten, + decorators: property.decorators, + crossLanguageDefinitionId: property.crossLanguageDefinitionId, + }; - return flattenedProperties; + return modelProperty; } } diff --git a/packages/http-client-csharp/emitter/src/type/input-type.ts b/packages/http-client-csharp/emitter/src/type/input-type.ts index e08341a2b3..2c43bdbbbd 100644 --- a/packages/http-client-csharp/emitter/src/type/input-type.ts +++ b/packages/http-client-csharp/emitter/src/type/input-type.ts @@ -106,7 +106,7 @@ export interface InputModelProperty extends InputTypeBase { readOnly: boolean; discriminator: boolean; crossLanguageDefinitionId: string; - flattenedNames?: string[]; // TODO -- remove this when we are ready to move the flatten handling from emitter to the generator + flatten: boolean; } export function isInputModelType(type: InputType): type is InputModelType { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs index 13e42ef9c7..89a4229598 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelProperty.cs @@ -1,13 +1,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.Collections.Generic; namespace Microsoft.Generator.CSharp.Input { public class InputModelProperty { - public InputModelProperty(string name, string serializedName, string? description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, IReadOnlyList? flattenedNames = null) + public InputModelProperty(string name, string serializedName, string? description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator) { Name = name; SerializedName = serializedName; @@ -16,7 +17,6 @@ public InputModelProperty(string name, string serializedName, string? descriptio IsRequired = isRequired; IsReadOnly = isReadOnly; IsDiscriminator = isDiscriminator; - FlattenedNames = flattenedNames ?? []; } public string Name { get; } @@ -27,7 +27,6 @@ public InputModelProperty(string name, string serializedName, string? descriptio public bool IsReadOnly { get; } public bool IsDiscriminator { get; } public InputModelType? EnclosingType { get; internal set; } - public IReadOnlyList FlattenedNames { get; } public IReadOnlyList Decorators { get; internal set; } = new List(); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs index 35667de491..bdac4f9795 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/InputModelType.cs @@ -103,8 +103,7 @@ internal set DiscriminatorProperty.Type, DiscriminatorProperty.IsRequired, DiscriminatorProperty.IsReadOnly, - DiscriminatorProperty.IsDiscriminator, - DiscriminatorProperty.FlattenedNames), + DiscriminatorProperty.IsDiscriminator), new Dictionary(), null, false) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs index 44f5ef09b9..400863e9a1 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.Input/src/InputTypes/Serialization/TypeSpecInputModelPropertyConverter.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using System; @@ -33,7 +33,6 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read bool isOptional = false; bool isDiscriminator = false; IReadOnlyList? decorators = null; - IReadOnlyList? flattenedNames = null; while (reader.TokenType != JsonTokenType.EndObject) { @@ -45,8 +44,7 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read || reader.TryReadBoolean("readOnly", ref isReadOnly) || reader.TryReadBoolean("optional", ref isOptional) || reader.TryReadBoolean("discriminator", ref isDiscriminator) - || reader.TryReadWithConverter("decorators", options, ref decorators) - || reader.TryReadWithConverter("flattenNames", options, ref flattenedNames); + || reader.TryReadWithConverter("decorators", options, ref decorators); if (!isKnownProperty) { @@ -59,7 +57,7 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read // description = BuilderHelpers.EscapeXmlDocDescription(description); propertyType = propertyType ?? throw new JsonException($"{nameof(InputModelProperty)} must have a property type."); - var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, !isOptional, isReadOnly, isDiscriminator, flattenedNames) { Decorators = decorators ?? [] }; + var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, !isOptional, isReadOnly, isDiscriminator) { Decorators = decorators ?? [] }; if (id != null) { resolver.AddReference(id, property); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/InputFactory.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/InputFactory.cs index 6abba938e5..ea1f6c67b4 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/InputFactory.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/InputFactory.cs @@ -146,8 +146,7 @@ public static InputModelProperty Property( type, isRequired, isReadOnly, - isDiscriminator, - null); + isDiscriminator); } public static InputModelType Model( diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json index bf69592830..2b05e6e1b2 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json @@ -27,6 +27,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Authentication.ApiKey.InvalidAuth.error" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json index b87047cb0b..072db5ad25 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json @@ -27,6 +27,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Authentication.Http.Custom.InvalidAuth.error" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/tspCodeModel.json index fff76822f9..d2ffcd3be7 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/tspCodeModel.json @@ -27,6 +27,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Authentication.OAuth2.InvalidAuth.error" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/tspCodeModel.json index 6caf5834ba..fb5538c0d4 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/tspCodeModel.json @@ -118,6 +118,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Client.Naming.Property.ClientNameModel.defaultName" } @@ -147,6 +148,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Client.Naming.Property.LanguageClientNameModel.defaultName" } @@ -176,6 +178,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Client.Naming.Property.ClientNameAndJsonEncodedNameModel.defaultName" } @@ -205,6 +208,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Client.Naming.Model.ModelWithClientClientName.defaultName" } @@ -234,6 +238,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Client.Naming.Model.ModelWithLanguageClientName.defaultName" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/bytes/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/bytes/tspCodeModel.json index c0011c47ed..f5bc01960d 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/bytes/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/bytes/tspCodeModel.json @@ -28,6 +28,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Bytes.DefaultBytesProperty.value" } @@ -57,6 +58,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Bytes.Base64BytesProperty.value" } @@ -86,6 +88,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Bytes.Base64urlBytesProperty.value" } @@ -130,6 +133,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Bytes.Base64urlArrayBytesProperty.value" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/datetime/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/datetime/tspCodeModel.json index fa5b930d09..0b5ace378b 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/datetime/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/datetime/tspCodeModel.json @@ -35,6 +35,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Datetime.DefaultDatetimeProperty.value" } @@ -71,6 +72,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Datetime.Rfc3339DatetimeProperty.value" } @@ -107,6 +109,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Datetime.Rfc7231DatetimeProperty.value" } @@ -143,6 +146,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Datetime.UnixTimestampDatetimeProperty.value" } @@ -201,6 +205,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Datetime.UnixTimestampArrayDatetimeProperty.value" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/duration/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/duration/tspCodeModel.json index 41b0099c5c..756e645c6e 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/duration/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/duration/tspCodeModel.json @@ -35,6 +35,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Duration.Property.DefaultDurationProperty.value" } @@ -71,6 +72,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Duration.Property.ISO8601DurationProperty.value" } @@ -107,6 +109,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Duration.Property.Int32SecondsDurationProperty.value" } @@ -143,6 +146,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Duration.Property.FloatSecondsDurationProperty.value" } @@ -179,6 +183,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Duration.Property.Float64SecondsDurationProperty.value" } @@ -237,6 +242,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Encode.Duration.Property.FloatSecondsDurationArrayProperty.value" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/basic/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/basic/tspCodeModel.json index bcfa21de90..d814c4776a 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/basic/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/basic/tspCodeModel.json @@ -27,6 +27,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Parameters.Basic.ImplicitBody.simple.Request.anonymous.name" } @@ -56,6 +57,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Parameters.Basic.ExplicitBody.User.name" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/spread/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/spread/tspCodeModel.json index 3ad965814f..cfe31e60fb 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/spread/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/spread/tspCodeModel.json @@ -27,6 +27,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Parameters.Spread.Alias.spreadAsRequestBody.Request.anonymous.name" } @@ -55,6 +56,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "spreadParameterWithInnerModel.Request.anonymous.name" } @@ -83,6 +85,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "spreadAsRequestParameter.Request.anonymous.name" } @@ -112,6 +115,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "spreadWithMultipleParameters.Request.anonymous.requiredString" }, @@ -131,6 +135,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "spreadWithMultipleParameters.Request.anonymous.optionalInt" }, @@ -157,6 +162,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "spreadWithMultipleParameters.Request.anonymous.requiredIntList" }, @@ -183,6 +189,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "spreadWithMultipleParameters.Request.anonymous.optionalStringList" } @@ -212,6 +219,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "spreadParameterWithInnerAlias.Request.anonymous.name" }, @@ -231,6 +239,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "spreadParameterWithInnerAlias.Request.anonymous.age" } @@ -260,6 +269,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Parameters.Spread.Model.BodyParameter.name" } @@ -288,6 +298,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "spreadCompositeRequestMix.Request.anonymous.prop" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/multipart/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/multipart/tspCodeModel.json index fbaa290d7d..784d80176f 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/multipart/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/multipart/tspCodeModel.json @@ -61,6 +61,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.MultiPartRequest.id" }, @@ -80,6 +81,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.MultiPartRequest.profileImage" } @@ -108,6 +110,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.ComplexPartsRequest.id" }, @@ -139,6 +142,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.Address.city" } @@ -147,6 +151,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.ComplexPartsRequest.address" }, @@ -166,6 +171,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.ComplexPartsRequest.profileImage" }, @@ -192,6 +198,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.ComplexPartsRequest.pictures" } @@ -219,6 +226,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.JsonPartRequest.address" }, @@ -238,6 +246,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.JsonPartRequest.profileImage" } @@ -266,6 +275,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.BinaryArrayPartsRequest.id" }, @@ -292,6 +302,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.BinaryArrayPartsRequest.pictures" } @@ -321,6 +332,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.MultiBinaryPartsRequest.profileImage" }, @@ -340,6 +352,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.MultiBinaryPartsRequest.picture" } @@ -369,6 +382,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "anonymousModel.Request.anonymous.profileImage" } @@ -397,6 +411,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.ComplexHttpPartsModelRequest.id" }, @@ -411,6 +426,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.ComplexHttpPartsModelRequest.address" }, @@ -449,6 +465,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "TypeSpec.Http.File.contentType" }, @@ -467,6 +484,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "TypeSpec.Http.File.filename" }, @@ -486,6 +504,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "TypeSpec.Http.File.contents" } @@ -507,6 +526,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.FileRequiredMetaData.filename" }, @@ -525,6 +545,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.FileRequiredMetaData.contentType" } @@ -533,6 +554,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.ComplexHttpPartsModelRequest.profileImage" }, @@ -554,6 +576,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.ComplexHttpPartsModelRequest.previousAddresses" }, @@ -575,6 +598,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.ComplexHttpPartsModelRequest.pictures" } @@ -609,6 +633,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.FormData.HttpParts.NonString.float.Request.anonymous.temperature" } @@ -662,6 +687,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.FileSpecificContentType.filename" }, @@ -682,6 +708,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.FileSpecificContentType.contentType" } @@ -690,6 +717,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.FileWithHttpPartSpecificContentTypeRequest.profileImage" } @@ -717,6 +745,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.FileWithHttpPartRequiredContentTypeRequest.profileImage" } @@ -761,6 +790,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.FileOptionalContentType.filename" } @@ -769,6 +799,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.MultiPart.FileWithHttpPartOptionalContentTypeRequest.profileImage" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/tspCodeModel.json index 47618ee9fc..98d2fe338c 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/tspCodeModel.json @@ -42,6 +42,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.SimpleModel.name" }, @@ -60,6 +61,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.SimpleModel.age" } @@ -68,6 +70,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNames.modelData" }, @@ -93,6 +96,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.ModelWithEncodedNames.colors" } @@ -137,6 +141,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.ModelWithDictionary.metadata" } @@ -166,6 +171,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [ { "$id": "20", @@ -192,6 +198,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [ { "$id": "24", @@ -232,6 +239,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.ModelWithEmptyArray.items" } @@ -266,6 +274,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [ { "$id": "33", @@ -289,6 +298,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [ { "$id": "36", @@ -334,6 +344,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [ { "$id": "42", @@ -375,6 +386,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [ { "$id": "49", @@ -420,6 +432,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [ { "$id": "55", @@ -453,6 +466,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.ModelWithUnwrappedArray.counts" } @@ -482,6 +496,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [ { "$id": "63", @@ -508,6 +523,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [ { "$id": "67", @@ -534,6 +550,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.ModelWithAttributes.enabled" } @@ -563,6 +580,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalField.item" }, @@ -581,6 +599,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.ModelWithOptionalField.value" } @@ -613,6 +632,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.ModelWithArrayOfModel.items" } @@ -649,6 +669,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArrays.colors" }, @@ -674,6 +695,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Payload.Xml.ModelWithSimpleArrays.counts" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/array/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/array/tspCodeModel.json index 18dab90fc5..bf6453be34 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/array/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/array/tspCodeModel.json @@ -29,6 +29,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Array.InnerModel.property" }, @@ -50,6 +51,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Array.InnerModel.children" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/dictionary/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/dictionary/tspCodeModel.json index 15a3d88431..1ad143cb41 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/dictionary/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/dictionary/tspCodeModel.json @@ -29,6 +29,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Dictionary.InnerModel.property" }, @@ -55,6 +56,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Dictionary.InnerModel.children" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/tspCodeModel.json index 62faa1a8f8..fd6a4b1e53 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/tspCodeModel.json @@ -101,6 +101,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.EnumDiscriminator.Dog.kind" }, @@ -124,6 +125,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.EnumDiscriminator.Dog.weight" } @@ -165,6 +167,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.EnumDiscriminator.Golden.kind" } @@ -195,6 +198,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.EnumDiscriminator.Snake.kind" }, @@ -218,6 +222,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.EnumDiscriminator.Snake.length" } @@ -259,6 +264,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.EnumDiscriminator.Cobra.kind" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/tspCodeModel.json index e9dcabb0a5..f2f757a85b 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/tspCodeModel.json @@ -27,6 +27,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Bird.kind" }, @@ -49,6 +50,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Bird.wingspan" } @@ -89,6 +91,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.SeaGull.kind" } @@ -128,6 +131,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Sparrow.kind" } @@ -167,6 +171,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Goose.kind" } @@ -206,6 +211,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Eagle.kind" }, @@ -227,6 +233,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Eagle.friends" }, @@ -253,6 +260,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Eagle.hate" }, @@ -267,6 +275,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Eagle.partner" } @@ -310,6 +319,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Dinosaur.kind" }, @@ -332,6 +342,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.Dinosaur.size" } @@ -372,6 +383,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Inheritance.SingleDiscriminator.TRex.kind" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/usage/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/usage/tspCodeModel.json index e17f9eee01..e081f12a51 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/usage/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/usage/tspCodeModel.json @@ -28,6 +28,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Usage.InputRecord.requiredProp" } @@ -57,6 +58,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Usage.OutputRecord.requiredProp" } @@ -86,6 +88,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Model.Usage.InputOutputRecord.requiredProp" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/additional-properties/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/additional-properties/tspCodeModel.json index 3ea1d8a1bf..46bbbab792 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/additional-properties/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/additional-properties/tspCodeModel.json @@ -146,6 +146,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.WidgetData2.kind" }, @@ -164,6 +165,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.WidgetData2.start" } @@ -197,6 +199,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.WidgetData1.kind" }, @@ -223,6 +226,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.WidgetData1.start" }, @@ -249,6 +253,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.WidgetData1.end" } @@ -274,6 +279,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion3.name" } @@ -324,6 +330,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion2.name" } @@ -367,6 +374,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.WidgetData0.kind" }, @@ -385,6 +393,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.WidgetData0.fooProp" } @@ -413,6 +422,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion.name" } @@ -460,6 +470,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.SpreadRecordForDiscriminatedUnion.name" } @@ -512,6 +523,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.SpreadRecordForUnion.flag" } @@ -564,6 +576,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.MultipleSpreadRecord.flag" } @@ -614,6 +627,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ModelForRecord.state" } @@ -638,6 +652,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.DifferentSpreadModelArrayRecord.knownProp" } @@ -663,6 +678,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.DifferentSpreadModelArrayDerived.derivedProp" } @@ -709,6 +725,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.DifferentSpreadModelRecord.knownProp" } @@ -727,6 +744,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.DifferentSpreadModelDerived.derivedProp" } @@ -775,6 +793,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.DifferentSpreadFloatRecord.name" } @@ -797,6 +816,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.DifferentSpreadFloatDerived.derivedProp" } @@ -845,6 +865,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.DifferentSpreadStringRecord.id" } @@ -867,6 +888,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.DifferentSpreadStringDerived.derivedProp" } @@ -911,6 +933,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.SpreadModelArrayRecord.knownProp" } @@ -953,6 +976,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsModelArrayAdditionalProperties.knownProp" } @@ -995,6 +1019,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsModelArrayAdditionalProperties.knownProp" } @@ -1023,6 +1048,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.SpreadModelRecord.knownProp" } @@ -1051,6 +1077,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsModelAdditionalProperties.knownProp" } @@ -1079,6 +1106,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsModelAdditionalProperties.knownProp" } @@ -1116,6 +1144,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.SpreadFloatRecord.id" } @@ -1153,6 +1182,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsFloatAdditionalProperties.id" } @@ -1190,6 +1220,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsFloatAdditionalProperties.id" } @@ -1227,6 +1258,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.SpreadStringRecord.name" } @@ -1264,6 +1296,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsStringAdditionalProperties.name" } @@ -1301,6 +1334,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsStringAdditionalProperties.name" } @@ -1337,6 +1371,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDiscriminated.kind" }, @@ -1357,6 +1392,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDiscriminated.name" }, @@ -1400,6 +1436,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDiscriminatedDerived.kind" }, @@ -1419,6 +1456,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDiscriminatedDerived.index" }, @@ -1438,6 +1476,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDiscriminatedDerived.age" } @@ -1488,6 +1527,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsUnknownAdditionalProperties.name" } @@ -1510,6 +1550,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDerived.index" }, @@ -1529,6 +1570,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDerived.age" } @@ -1568,6 +1610,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDiscriminated.kind" }, @@ -1588,6 +1631,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDiscriminated.name" }, @@ -1631,6 +1675,7 @@ "optional": false, "readOnly": false, "discriminator": true, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.kind" }, @@ -1650,6 +1695,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.index" }, @@ -1669,6 +1715,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.age" } @@ -1719,6 +1766,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalProperties.name" } @@ -1741,6 +1789,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDerived.index" }, @@ -1760,6 +1809,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDerived.age" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/nullable/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/nullable/tspCodeModel.json index f9a30f13a9..357d8269d3 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/nullable/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/nullable/tspCodeModel.json @@ -29,6 +29,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.CollectionsStringProperty.requiredProperty" }, @@ -59,6 +60,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.CollectionsStringProperty.nullableProperty" } @@ -89,6 +91,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.CollectionsModelProperty.requiredProperty" }, @@ -130,6 +133,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.InnerModel.property" } @@ -142,6 +146,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.CollectionsModelProperty.nullableProperty" } @@ -175,6 +180,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.CollectionsByteProperty.requiredProperty" }, @@ -206,6 +212,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.CollectionsByteProperty.nullableProperty" } @@ -236,6 +243,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.DurationProperty.requiredProperty" }, @@ -267,6 +275,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.DurationProperty.nullableProperty" } @@ -297,6 +306,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.DatetimeProperty.requiredProperty" }, @@ -328,6 +338,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.DatetimeProperty.nullableProperty" } @@ -358,6 +369,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.BytesProperty.requiredProperty" }, @@ -382,6 +394,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.BytesProperty.nullableProperty" } @@ -412,6 +425,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.StringProperty.requiredProperty" }, @@ -435,6 +449,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Nullable.StringProperty.nullableProperty" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/optionality/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/optionality/tspCodeModel.json index bc4de0cbe6..d79bec1424 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/optionality/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/optionality/tspCodeModel.json @@ -288,6 +288,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.RequiredAndOptionalProperty.optionalProperty" }, @@ -307,6 +308,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.RequiredAndOptionalProperty.requiredProperty" } @@ -333,6 +335,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.UnionFloatLiteralProperty.property" } @@ -359,6 +362,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.UnionIntLiteralProperty.property" } @@ -385,6 +389,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.UnionStringLiteralProperty.property" } @@ -421,6 +426,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.BooleanLiteralProperty.property" } @@ -453,6 +459,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.FloatLiteralProperty.property" } @@ -485,6 +492,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.IntLiteralProperty.property" } @@ -517,6 +525,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.StringLiteralProperty.property" } @@ -566,6 +575,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.StringProperty.property" } @@ -577,6 +587,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.CollectionsModelProperty.property" } @@ -618,6 +629,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.CollectionsByteProperty.property" } @@ -648,6 +660,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.PlainTimeProperty.property" } @@ -678,6 +691,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.PlainDateProperty.property" } @@ -716,6 +730,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.DurationProperty.property" } @@ -754,6 +769,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.DatetimeProperty.property" } @@ -785,6 +801,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.Optional.BytesProperty.property" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/value-types/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/value-types/tspCodeModel.json index 9c9bf2a317..b516e8718f 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/value-types/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/value-types/tspCodeModel.json @@ -438,6 +438,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.UnionEnumValueProperty.property" } @@ -464,6 +465,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.UnionFloatLiteralProperty.property" } @@ -490,6 +492,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.UnionIntLiteralProperty.property" } @@ -516,6 +519,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.UnionStringLiteralProperty.property" } @@ -552,6 +556,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.BooleanLiteralProperty.property" } @@ -584,6 +589,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.FloatLiteralProperty.property" } @@ -616,6 +622,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.IntLiteralProperty.property" } @@ -648,6 +655,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.StringLiteralProperty.property" } @@ -678,6 +686,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.UnknownArrayProperty.property" } @@ -708,6 +717,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.UnknownDictProperty.property" } @@ -738,6 +748,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.UnknownIntProperty.property" } @@ -768,6 +779,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.UnknownStringProperty.property" } @@ -820,6 +832,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.DictionaryStringProperty.property" } @@ -869,6 +882,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.InnerModel.property" } @@ -880,6 +894,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.CollectionsModelProperty.property" } @@ -920,6 +935,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.CollectionsIntProperty.property" } @@ -957,6 +973,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.CollectionsStringProperty.property" } @@ -983,6 +1000,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.ModelProperty.property" } @@ -1009,6 +1027,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.ExtensibleEnumProperty.property" } @@ -1035,6 +1054,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.EnumProperty.property" } @@ -1073,6 +1093,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.DurationProperty.property" } @@ -1111,6 +1132,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.DatetimeProperty.property" } @@ -1141,6 +1163,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.Decimal128Property.property" } @@ -1171,6 +1194,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.DecimalProperty.property" } @@ -1201,6 +1225,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.FloatProperty.property" } @@ -1231,6 +1256,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.IntProperty.property" } @@ -1262,6 +1288,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.BytesProperty.property" } @@ -1292,6 +1319,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.StringProperty.property" } @@ -1322,6 +1350,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Property.ValueTypes.BooleanProperty.property" } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/union/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/union/tspCodeModel.json index eef77a41a3..130cc0db5b 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/union/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/union/tspCodeModel.json @@ -516,6 +516,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.Cat.name" } @@ -554,6 +555,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.MixedTypesCases.model" }, @@ -604,6 +606,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.MixedTypesCases.literal" }, @@ -654,6 +657,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.MixedTypesCases.int" }, @@ -704,6 +708,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.MixedTypesCases.boolean" }, @@ -761,6 +766,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.MixedTypesCases.array" } @@ -769,6 +775,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.get.Response.anonymous.prop" } @@ -799,6 +806,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.send.Request.anonymous.prop" } @@ -894,6 +902,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.MixedLiteralsCases.stringLiteral" }, @@ -966,6 +975,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.MixedLiteralsCases.intLiteral" }, @@ -1038,6 +1048,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.MixedLiteralsCases.floatLiteral" }, @@ -1110,6 +1121,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.MixedLiteralsCases.booleanLiteral" } @@ -1118,6 +1130,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.get.Response.anonymous.prop" } @@ -1145,6 +1158,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.send.Request.anonymous.prop" } @@ -1209,6 +1223,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.StringAndArrayCases.string" }, @@ -1250,6 +1265,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.StringAndArrayCases.array" } @@ -1258,6 +1274,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.get.Response.anonymous.prop" } @@ -1285,6 +1302,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.send.Request.anonymous.prop" } @@ -1323,6 +1341,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.EnumsOnlyCases.lr" }, @@ -1338,6 +1357,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.EnumsOnlyCases.ud" } @@ -1346,6 +1366,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.get.Response.anonymous.prop" } @@ -1373,6 +1394,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.send.Request.anonymous.prop" } @@ -1422,6 +1444,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.Dog.bark" } @@ -1433,6 +1456,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.get.Response.anonymous.prop" } @@ -1471,6 +1495,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.send.Request.anonymous.prop" } @@ -1495,6 +1520,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.get.Response.anonymous.prop" } @@ -1519,6 +1545,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.send.Request.anonymous.prop" } @@ -1543,6 +1570,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.get.Response.anonymous.prop" } @@ -1567,6 +1595,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.send.Request.anonymous.prop" } @@ -1591,6 +1620,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.get.Response.anonymous.prop" } @@ -1615,6 +1645,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.send.Request.anonymous.prop" } @@ -1639,6 +1670,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.get.Response.anonymous.prop" } @@ -1663,6 +1695,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.send.Request.anonymous.prop" } @@ -1687,6 +1720,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.get.Response.anonymous.prop" } @@ -1711,6 +1745,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "Type.Union.send.Request.anonymous.prop" } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json index 59f157390c..cbce2fcc40 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json @@ -852,6 +852,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.name" }, @@ -900,6 +901,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.requiredUnion" }, @@ -921,6 +923,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.requiredLiteralString" }, @@ -942,6 +945,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.requiredLiteralInt" }, @@ -963,6 +967,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.requiredLiteralFloat" }, @@ -988,6 +993,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.requiredLiteralBool" }, @@ -1009,6 +1015,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.optionalLiteralString" }, @@ -1030,6 +1037,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.optionalLiteralInt" }, @@ -1051,6 +1059,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.optionalLiteralFloat" }, @@ -1076,6 +1085,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.optionalLiteralBool" }, @@ -1095,6 +1105,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.requiredBadDescription" }, @@ -1125,6 +1136,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.optionalNullableList" }, @@ -1155,6 +1167,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.Thing.requiredNullableList" } @@ -1185,6 +1198,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.requiredString" }, @@ -1205,6 +1219,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.requiredInt" }, @@ -1227,6 +1242,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.requiredCollection" }, @@ -1254,6 +1270,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.requiredDictionary" }, @@ -1269,6 +1286,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.requiredModel" }, @@ -1284,6 +1302,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.intExtensibleEnum" }, @@ -1306,6 +1325,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.intExtensibleEnumCollection" }, @@ -1321,6 +1341,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.floatExtensibleEnum" }, @@ -1336,6 +1357,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.floatExtensibleEnumWithIntValue" }, @@ -1358,6 +1380,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.floatExtensibleEnumCollection" }, @@ -1373,6 +1396,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.floatFixedEnum" }, @@ -1388,6 +1412,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.floatFixedEnumWithIntValue" }, @@ -1410,6 +1435,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.floatFixedEnumCollection" }, @@ -1425,6 +1451,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.intFixedEnum" }, @@ -1447,6 +1474,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.intFixedEnumCollection" }, @@ -1462,6 +1490,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.stringFixedEnum" }, @@ -1481,6 +1510,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.requiredUnknown" }, @@ -1500,6 +1530,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.optionalUnknown" }, @@ -1531,6 +1562,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.requiredRecordUnknown" }, @@ -1562,6 +1594,7 @@ "optional": true, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.optionalRecordUnknown" }, @@ -1593,6 +1626,7 @@ "optional": false, "readOnly": true, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.readOnlyRequiredRecordUnknown" }, @@ -1624,6 +1658,7 @@ "optional": true, "readOnly": true, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.readOnlyOptionalRecordUnknown" }, @@ -1662,6 +1697,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.ModelWithRequiredNullableProperties.requiredNullablePrimitive" }, @@ -1681,6 +1717,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.ModelWithRequiredNullableProperties.requiredExtensibleEnum" }, @@ -1700,6 +1737,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.ModelWithRequiredNullableProperties.requiredFixedEnum" } @@ -1708,6 +1746,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.modelWithRequiredNullable" }, @@ -1728,6 +1767,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.RoundTripModel.requiredBytes" } @@ -1761,6 +1801,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.NotFriend.name" } @@ -1791,6 +1832,7 @@ "optional": false, "readOnly": false, "discriminator": false, + "flatten": false, "decorators": [], "crossLanguageDefinitionId": "UnbrandedTypeSpec.ModelWithProjectedName.name" } From 010ebded10a3844f8cc4bdbd97072cc75a681065 Mon Sep 17 00:00:00 2001 From: Swati Kumar Date: Wed, 9 Oct 2024 08:07:30 -0700 Subject: [PATCH 04/13] Add missing exit callbacks (#4626) Fixes: https://github.com/microsoft/typespec/issues/4588 This won't call the post order exit callbacks if recursion stops at pre-order callbacks. --------- Co-authored-by: swatikumar --- ...manticWalkerExitFixes-2024-9-9-10-27-23.md | 7 + packages/compiler/src/core/semantic-walker.ts | 14 ++ .../compiler/test/semantic-walker.test.ts | 183 +++++++++++++++++- 3 files changed, 198 insertions(+), 6 deletions(-) create mode 100644 .chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md diff --git a/.chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md b/.chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md new file mode 100644 index 0000000000..b380c8573e --- /dev/null +++ b/.chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/compiler" +--- + +Fix #4588 \ No newline at end of file diff --git a/packages/compiler/src/core/semantic-walker.ts b/packages/compiler/src/core/semantic-walker.ts index e32ee72630..a9e689138b 100644 --- a/packages/compiler/src/core/semantic-walker.ts +++ b/packages/compiler/src/core/semantic-walker.ts @@ -194,6 +194,8 @@ function navigateNamespaceType(namespace: Namespace, context: NavigationContext) for (const decorator of namespace.decoratorDeclarations.values()) { navigateDecoratorDeclaration(decorator, context); } + + context.emit("exitNamespace", namespace); } function checkVisited(visited: Set, item: Type) { @@ -288,6 +290,8 @@ function navigateInterfaceType(type: Interface, context: NavigationContext) { for (const op of type.operations.values()) { navigateOperationType(op, context); } + + context.emit("exitInterface", type); } function navigateEnumType(type: Enum, context: NavigationContext) { @@ -296,6 +300,11 @@ function navigateEnumType(type: Enum, context: NavigationContext) { } context.emit("enum", type); + for (const member of type.members.values()) { + navigateTypeInternal(member, context); + } + + context.emit("exitEnum", type); } function navigateUnionType(type: Union, context: NavigationContext) { @@ -309,6 +318,8 @@ function navigateUnionType(type: Union, context: NavigationContext) { for (const variant of type.variants.values()) { navigateUnionTypeVariant(variant, context); } + + context.emit("exitUnion", type); } function navigateUnionTypeVariant(type: UnionVariant, context: NavigationContext) { @@ -317,6 +328,8 @@ function navigateUnionTypeVariant(type: UnionVariant, context: NavigationContext } if (context.emit("unionVariant", type) === ListenerFlow.NoRecursion) return; navigateTypeInternal(type.type, context); + + context.emit("exitUnionVariant", type); } function navigateTupleType(type: Tuple, context: NavigationContext) { @@ -327,6 +340,7 @@ function navigateTupleType(type: Tuple, context: NavigationContext) { for (const value of type.values) { navigateTypeInternal(value, context); } + context.emit("exitTuple", type); } function navigateStringTemplate(type: StringTemplate, context: NavigationContext) { diff --git a/packages/compiler/test/semantic-walker.test.ts b/packages/compiler/test/semantic-walker.test.ts index 5240e001db..8d35b1c883 100644 --- a/packages/compiler/test/semantic-walker.test.ts +++ b/packages/compiler/test/semantic-walker.test.ts @@ -1,6 +1,7 @@ import { deepStrictEqual, ok, strictEqual } from "assert"; import { beforeEach, describe, it } from "vitest"; import { + Enum, Interface, ListenerFlow, Model, @@ -29,18 +30,24 @@ describe("compiler: semantic walker", () => { function createCollector(customListener?: SemanticNodeListener) { const result = { + enums: [] as Enum[], + exitEnums: [] as Enum[], + interfaces: [] as Interface[], + exitInterfaces: [] as Interface[], models: [] as Model[], exitModels: [] as Model[], modelProperties: [] as ModelProperty[], exitModelProperties: [] as ModelProperty[], namespaces: [] as Namespace[], + exitNamespaces: [] as Namespace[], operations: [] as Operation[], exitOperations: [] as Operation[], - interfaces: [] as Interface[], - unions: [] as Union[], - unionVariants: [] as UnionVariant[], tuples: [] as Tuple[], exitTuples: [] as Tuple[], + unions: [] as Union[], + exitUnions: [] as Union[], + unionVariants: [] as UnionVariant[], + exitUnionVariants: [] as UnionVariant[], }; const listener: SemanticNodeListener = { @@ -48,6 +55,10 @@ describe("compiler: semantic walker", () => { result.namespaces.push(x); return customListener?.namespace?.(x); }, + exitNamespace: (x) => { + result.exitNamespaces.push(x); + return customListener?.exitNamespace?.(x); + }, operation: (x) => { result.operations.push(x); return customListener?.operation?.(x); @@ -72,17 +83,29 @@ describe("compiler: semantic walker", () => { result.exitModelProperties.push(x); return customListener?.exitModelProperty?.(x); }, + enum: (x) => { + result.enums.push(x); + return customListener?.enum?.(x); + }, + exitEnum: (x) => { + result.exitEnums.push(x); + return customListener?.exitEnum?.(x); + }, union: (x) => { result.unions.push(x); return customListener?.union?.(x); }, + exitUnion: (x) => { + result.exitUnions.push(x); + return customListener?.exitUnion?.(x); + }, interface: (x) => { result.interfaces.push(x); return customListener?.interface?.(x); }, - unionVariant: (x) => { - result.unionVariants.push(x); - return customListener?.unionVariant?.(x); + exitInterface: (x) => { + result.exitInterfaces.push(x); + return customListener?.exitInterface?.(x); }, tuple: (x) => { result.tuples.push(x); @@ -92,6 +115,14 @@ describe("compiler: semantic walker", () => { result.exitTuples.push(x); return customListener?.exitTuple?.(x); }, + unionVariant: (x) => { + result.unionVariants.push(x); + return customListener?.unionVariant?.(x); + }, + exitUnionVariant: (x) => { + result.exitUnionVariants.push(x); + return customListener?.exitUnionVariant?.(x); + }, }; return [result, listener] as const; } @@ -198,6 +229,31 @@ describe("compiler: semantic walker", () => { ); }); + it("finds exit namespaces", async () => { + const result = await runNavigator(` + namespace Global.My; + namespace Simple { + } + namespace Parent { + namespace Child { + } + } + `); + + deepStrictEqual( + result.exitNamespaces.map((x) => getNamespaceFullName(x)), + [ + "TypeSpec", + "Global.My.Simple", + "Global.My.Parent.Child", + "Global.My.Parent", + "Global.My", + "Global", + "", + ], + ); + }); + it("finds model properties", async () => { const result = await runNavigator(` model Foo { @@ -236,6 +292,94 @@ describe("compiler: semantic walker", () => { strictEqual(result.exitModelProperties[2].name, "name"); }); + it("finds enums", async () => { + const result = await runNavigator(` + enum Direction { + North: "north", + East: "east", + South: "south", + West: "west", + } + + enum Metric { + One: 1, + Ten: 10, + Hundred: 100, + } + `); + + strictEqual(result.enums.length, 2); + strictEqual(result.enums[0].name, "Direction"); + strictEqual(result.enums[1].name, "Metric"); + }); + + it("finds exit enums", async () => { + const result = await runNavigator(` + enum Direction { + North: "north", + East: "east", + South: "south", + West: "west", + } + + enum Metric { + One: 1, + Ten: 10, + Hundred: 100, + } + `); + + strictEqual(result.exitEnums.length, 2); + strictEqual(result.exitEnums[0].name, "Direction"); + strictEqual(result.exitEnums[1].name, "Metric"); + }); + + it("finds tuples with model", async () => { + const result = await runNavigator(` + model Foo { + bar: [Direction, Color] + } + + enum Direction { + North, + East, + South, + West, + } + + model Color { + value: string; + } + `); + + strictEqual(result.tuples.length, 1); + strictEqual(result.enums[0].name, "Direction"); + strictEqual(result.models[1].name, "Color"); + }); + + it("finds exit tuples with model", async () => { + const result = await runNavigator(` + model Foo { + bar: [Direction, Color] + } + + enum Direction { + North, + East, + South, + West, + } + + model Color { + value: string; + } + `); + + strictEqual(result.exitTuples.length, 1); + strictEqual(result.exitEnums[0].name, "Direction"); + strictEqual(result.exitModels[0].name, "Color"); + }); + it("finds unions", async () => { const result = await runNavigator(` union A { @@ -271,6 +415,19 @@ describe("compiler: semantic walker", () => { strictEqual(result.exitTuples[0].values.length, 1); }); + it("finds exit unions", async () => { + const result = await runNavigator(` + union A { + x: true; + } + `); + + strictEqual(result.exitUnions.length, 1); + strictEqual(result.exitUnions[0].name!, "A"); + strictEqual(result.exitUnionVariants.length, 1); + strictEqual(result.exitUnionVariants[0].name!, "x"); + }); + it("finds interfaces", async () => { const result = await runNavigator(` model B { }; @@ -285,6 +442,20 @@ describe("compiler: semantic walker", () => { strictEqual(result.operations[0].name, "a"); }); + it("finds exit interfaces", async () => { + const result = await runNavigator(` + model B { }; + interface A { + a(): true; + } + `); + + strictEqual(result.exitInterfaces.length, 1, "finds interfaces"); + strictEqual(result.exitInterfaces[0].name, "A"); + strictEqual(result.exitOperations.length, 1, "finds operations"); + strictEqual(result.exitOperations[0].name, "a"); + }); + it("finds owned or inherited properties", async () => { const result = await runNavigator(` model Pet { From c479dac8a96951787111bf0241cbbb7e91942bc0 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 9 Oct 2024 10:28:08 -0700 Subject: [PATCH 05/13] Add release notes for 0.61 release (#4654) --- ...manticWalkerExitFixes-2024-9-9-10-27-23.md | 2 +- docs/release-notes/release-2024-10-09.md | 90 +++++++++++++++++++ packages/website/package.json | 3 + pnpm-lock.yaml | 9 ++ 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 docs/release-notes/release-2024-10-09.md diff --git a/.chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md b/.chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md index b380c8573e..9d91beab1f 100644 --- a/.chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md +++ b/.chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md @@ -4,4 +4,4 @@ packages: - "@typespec/compiler" --- -Fix #4588 \ No newline at end of file +[API] Add missing exit callback diff --git a/docs/release-notes/release-2024-10-09.md b/docs/release-notes/release-2024-10-09.md new file mode 100644 index 0000000000..bc8425df22 --- /dev/null +++ b/docs/release-notes/release-2024-10-09.md @@ -0,0 +1,90 @@ +--- +title: 0.61 - October 2024 +--- + +:::warning +This release contains breaking changes +::: + +## Breaking Changes + +### @typespec/compiler + +- [#4539](https://github.com/microsoft/typespec/pull/4539) Config parameters and emitters options cannot contains `.`. This conflict with newly added support for nested options. +- [#4500](https://github.com/microsoft/typespec/pull/4500) API: Update default of `decoratorArgMarshalling` from `legacy` to `new` + +To revert to the old behavior export the following. **Highly discouraged, this will be removed in a few versions.** + +```ts +export const $flags = definePackageFlags({ + decoratorArgMarshalling: "legacy", +}); +``` + +- TypeSpec compiler expect the entrypoint to be an absolute path. This used to work with some alternative `CompilerHost` that handled relative path but this is no longer supported due to the new `exports` field support. + +## Features + +### @typespec/compiler + +- [#4442](https://github.com/microsoft/typespec/pull/4442) Library diagnostic can now define a `description` and `url` that links to a more detailed doc for this diagnostic +- [#4290](https://github.com/microsoft/typespec/pull/4290) Adding experimental (unstable) API fro Type Mutators +- [#4595](https://github.com/microsoft/typespec/pull/4595) Expose more accurate `PackageJson` type and deprecate `NodePackage` +- [#4606](https://github.com/microsoft/typespec/pull/4606) Add support for node `exports` field. Specific typespec exports can be provided with the `typespec` field + +```json +"exports": { + ".": { + "typespec": "./lib/main.tsp", + }, + "./named": { + "typespec": "./lib/named.tsp", + } +} +``` + +- [#4539](https://github.com/microsoft/typespec/pull/4539) Support nested emitter options + +### @typespec/http + +- [#4513](https://github.com/microsoft/typespec/pull/4513) Adds HttpStream and JsonlStream models to to support streaming use-cases. + +### @typespec/openapi3 + +- [#4423](https://github.com/microsoft/typespec/pull/4423) Added support to use Scalar and Object as default types + +### @typespec/json-schema + +- [#4447](https://github.com/microsoft/typespec/pull/4447) Example set with `@example` decorator will populate the schema `examples` property + +### typespec-vscode + +- [#4330](https://github.com/microsoft/typespec/pull/4330) Support Compile Task and Watch Task in vscode. +- [#4498](https://github.com/microsoft/typespec/pull/4498) Make extension web compatible with minimal functionality + +## Bug Fixes + +### @typespec/compiler + +- [#4513](https://github.com/microsoft/typespec/pull/4513) Fixes issue with the semantic walker where `exitTuple` was not being emitted. +- [#4462](https://github.com/microsoft/typespec/pull/4462) Fix examples with enums inside of unions +- [#4574](https://github.com/microsoft/typespec/pull/4574) Fix: Passing `const` of model type to `@example` +- [#4551](https://github.com/microsoft/typespec/pull/4551) Json serialization of example respect `@encodedName` +- [#4514](https://github.com/microsoft/typespec/pull/4514) Fix issue with decimal numeric and leading `0.0` with multiple digit +- [#4445](https://github.com/microsoft/typespec/pull/4445) [API] model `sourceModels` property are now projected correctly +- [#4467](https://github.com/microsoft/typespec/pull/4467) Changing tspconfig.yaml won't take effect in LSP server because of the cache +- [#4563](https://github.com/microsoft/typespec/pull/4563) `tsp compile --watch` reread from `tspconfig.yaml` file +- [#4626](https://github.com/microsoft/typespec/pull/4626) [API] Add missing exit callback + +### @typespec/openapi + +- [#4505](https://github.com/microsoft/typespec/pull/4505) `@info` decorator validate no extra properties not starting with `x-` are provided. +- [#4483](https://github.com/microsoft/typespec/pull/4483) `@info` decorator validate `termsOfService` is a valid url + +### @typespec/internal-build-utils + +- [#4498](https://github.com/microsoft/typespec/pull/4498) Ignore test from third party notice generation + +### typespec-vscode + +- [#4430](https://github.com/microsoft/typespec/pull/4430) Use "shell" when spawning execution of .cmd file(i.e. tsp-server.cmd) in windows diff --git a/packages/website/package.json b/packages/website/package.json index ccd1a64527..d0f812d75a 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -55,6 +55,9 @@ "@typespec/json-schema": "workspace:~", "@typespec/openapi": "workspace:~", "@typespec/openapi3": "workspace:~", + "@typespec/events": "workspace:~", + "@typespec/streams": "workspace:~", + "@typespec/sse": "workspace:~", "@typespec/playground-website": "workspace:*", "@typespec/protobuf": "workspace:~", "@typespec/rest": "workspace:~", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8a2299f65e..82d45cd6c0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1963,6 +1963,9 @@ importers: '@typespec/compiler': specifier: workspace:~ version: link:../compiler + '@typespec/events': + specifier: workspace:~ + version: link:../events '@typespec/http': specifier: workspace:~ version: link:../http @@ -1990,6 +1993,12 @@ importers: '@typespec/spec': specifier: workspace:* version: link:../spec + '@typespec/sse': + specifier: workspace:~ + version: link:../sse + '@typespec/streams': + specifier: workspace:~ + version: link:../streams '@typespec/tspd': specifier: workspace:~ version: link:../tspd From 78238fb75a00248155cb290d29e4948128f6216f Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:34:58 -0700 Subject: [PATCH 06/13] Update STJ version (#4653) --- .../src/Primitives/NewProjectScaffolding.cs | 2 +- .../authentication/api-key/src/Authentication.ApiKey.csproj | 2 +- .../http/custom/src/Authentication.Http.Custom.csproj | 2 +- .../http/authentication/oauth2/src/Authentication.OAuth2.csproj | 2 +- .../http/authentication/union/src/Authentication.Union.csproj | 2 +- .../CadlRanch/http/client/naming/src/Client.Naming.csproj | 2 +- .../structure/multi-client/src/Client.Structure.Service.csproj | 2 +- .../CadlRanch/http/encode/bytes/src/Encode.Bytes.csproj | 2 +- .../CadlRanch/http/encode/datetime/src/Encode.Datetime.csproj | 2 +- .../CadlRanch/http/encode/duration/src/Encode.Duration.csproj | 2 +- .../CadlRanch/http/parameters/basic/src/Parameters.Basic.csproj | 2 +- .../http/parameters/spread/src/Parameters.Spread.csproj | 2 +- .../http/payload/media-type/src/Payload.MediaType.csproj | 2 +- .../http/payload/multipart/src/Payload.MultiPart.csproj | 2 +- .../CadlRanch/http/payload/xml/src/Payload.Xml.csproj | 2 +- .../http/server/path/single/src/Server.Path.Single.csproj | 2 +- .../not-versioned/src/Server.Versions.NotVersioned.csproj | 2 +- .../CadlRanch/http/type/array/src/_Type._Array.csproj | 2 +- .../CadlRanch/http/type/dictionary/src/_Type.Dictionary.csproj | 2 +- .../http/type/enum/extensible/src/_Type._Enum.Extensible.csproj | 2 +- .../CadlRanch/http/type/enum/fixed/src/_Type._Enum.Fixed.csproj | 2 +- .../http/type/model/empty/src/_Type.Model.Empty.csproj | 2 +- .../src/_Type.Model.Inheritance.EnumDiscriminator.csproj | 2 +- .../src/_Type.Model.Inheritance.SingleDiscriminator.csproj | 2 +- .../http/type/model/usage/src/_Type.Model.Usage.csproj | 2 +- .../src/_Type.Property.AdditionalProperties.csproj | 2 +- .../type/property/nullable/src/_Type.Property.Nullable.csproj | 2 +- .../property/optionality/src/_Type.Property.Optional.csproj | 2 +- .../property/value-types/src/_Type.Property.ValueTypes.csproj | 2 +- .../CadlRanch/http/type/scalar/src/_Type.Scalar.csproj | 2 +- .../CadlRanch/http/type/union/src/_Type.Union.csproj | 2 +- .../Local/Unbranded-TypeSpec/src/UnbrandedTypeSpec.csproj | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Primitives/NewProjectScaffolding.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Primitives/NewProjectScaffolding.cs index d078a4f501..e09558ffcc 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Primitives/NewProjectScaffolding.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Primitives/NewProjectScaffolding.cs @@ -73,7 +73,7 @@ private string GetSrcCSProj() private static readonly IReadOnlyList _unbrandedDependencyPackages = new CSProjWriter.CSProjDependencyPackage[] { new("System.ClientModel", "1.1.0-beta.4"), - new("System.Text.Json", "8.0.4") + new("System.Text.Json", "8.0.5") }; private string GetSln() diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/src/Authentication.ApiKey.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/src/Authentication.ApiKey.csproj index 4aff85a45d..97c6e92432 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/src/Authentication.ApiKey.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/src/Authentication.ApiKey.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/src/Authentication.Http.Custom.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/src/Authentication.Http.Custom.csproj index 9c2b55d1ba..3c6ec93395 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/src/Authentication.Http.Custom.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/src/Authentication.Http.Custom.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/src/Authentication.OAuth2.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/src/Authentication.OAuth2.csproj index f6dfc545aa..1606cc392d 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/src/Authentication.OAuth2.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/oauth2/src/Authentication.OAuth2.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/src/Authentication.Union.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/src/Authentication.Union.csproj index a379502592..d414fe14dd 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/src/Authentication.Union.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/src/Authentication.Union.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/src/Client.Naming.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/src/Client.Naming.csproj index 6c87383d9d..53d5a5d43b 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/src/Client.Naming.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/src/Client.Naming.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/structure/multi-client/src/Client.Structure.Service.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/structure/multi-client/src/Client.Structure.Service.csproj index cea7698168..f3f63de6af 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/structure/multi-client/src/Client.Structure.Service.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/client/structure/multi-client/src/Client.Structure.Service.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/bytes/src/Encode.Bytes.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/bytes/src/Encode.Bytes.csproj index 06898ef5e7..90e46fff7f 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/bytes/src/Encode.Bytes.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/bytes/src/Encode.Bytes.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/datetime/src/Encode.Datetime.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/datetime/src/Encode.Datetime.csproj index 9624bee8db..3d5a03274c 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/datetime/src/Encode.Datetime.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/datetime/src/Encode.Datetime.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/duration/src/Encode.Duration.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/duration/src/Encode.Duration.csproj index f5265c74d8..ecd5127759 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/duration/src/Encode.Duration.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/encode/duration/src/Encode.Duration.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/basic/src/Parameters.Basic.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/basic/src/Parameters.Basic.csproj index ac98e3a984..a9ddf2c8f5 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/basic/src/Parameters.Basic.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/basic/src/Parameters.Basic.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/spread/src/Parameters.Spread.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/spread/src/Parameters.Spread.csproj index abe69cf3c5..9558e522eb 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/spread/src/Parameters.Spread.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/parameters/spread/src/Parameters.Spread.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Payload.MediaType.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Payload.MediaType.csproj index c63aebd443..77cbe0d99e 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Payload.MediaType.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/media-type/src/Payload.MediaType.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/multipart/src/Payload.MultiPart.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/multipart/src/Payload.MultiPart.csproj index 2c3e0735c8..378cd2b306 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/multipart/src/Payload.MultiPart.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/multipart/src/Payload.MultiPart.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/src/Payload.Xml.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/src/Payload.Xml.csproj index 21dc530cba..8e68e7a868 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/src/Payload.Xml.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/payload/xml/src/Payload.Xml.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Server.Path.Single.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Server.Path.Single.csproj index 9fb8e6a5ea..98c14c633d 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Server.Path.Single.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/path/single/src/Server.Path.Single.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/versions/not-versioned/src/Server.Versions.NotVersioned.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/versions/not-versioned/src/Server.Versions.NotVersioned.csproj index f0c4f735fa..3514de6e87 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/versions/not-versioned/src/Server.Versions.NotVersioned.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/server/versions/not-versioned/src/Server.Versions.NotVersioned.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/array/src/_Type._Array.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/array/src/_Type._Array.csproj index d050bef50b..49cdb09198 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/array/src/_Type._Array.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/array/src/_Type._Array.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/dictionary/src/_Type.Dictionary.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/dictionary/src/_Type.Dictionary.csproj index daeff46832..69c172da79 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/dictionary/src/_Type.Dictionary.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/dictionary/src/_Type.Dictionary.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/enum/extensible/src/_Type._Enum.Extensible.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/enum/extensible/src/_Type._Enum.Extensible.csproj index a362dfb2bc..644789befd 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/enum/extensible/src/_Type._Enum.Extensible.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/enum/extensible/src/_Type._Enum.Extensible.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/enum/fixed/src/_Type._Enum.Fixed.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/enum/fixed/src/_Type._Enum.Fixed.csproj index fb8bf6dc5d..6530006e88 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/enum/fixed/src/_Type._Enum.Fixed.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/enum/fixed/src/_Type._Enum.Fixed.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/empty/src/_Type.Model.Empty.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/empty/src/_Type.Model.Empty.csproj index 5275288d59..bd7a5312be 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/empty/src/_Type.Model.Empty.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/empty/src/_Type.Model.Empty.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/_Type.Model.Inheritance.EnumDiscriminator.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/_Type.Model.Inheritance.EnumDiscriminator.csproj index c19bc462ba..b7372db1c1 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/_Type.Model.Inheritance.EnumDiscriminator.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/enum-discriminator/src/_Type.Model.Inheritance.EnumDiscriminator.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/_Type.Model.Inheritance.SingleDiscriminator.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/_Type.Model.Inheritance.SingleDiscriminator.csproj index 15eb32f848..6e44f455de 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/_Type.Model.Inheritance.SingleDiscriminator.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/inheritance/single-discriminator/src/_Type.Model.Inheritance.SingleDiscriminator.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/usage/src/_Type.Model.Usage.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/usage/src/_Type.Model.Usage.csproj index c0a22e4f8e..76cbabc3c2 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/usage/src/_Type.Model.Usage.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/model/usage/src/_Type.Model.Usage.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/additional-properties/src/_Type.Property.AdditionalProperties.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/additional-properties/src/_Type.Property.AdditionalProperties.csproj index fdab703fed..a66982eff2 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/additional-properties/src/_Type.Property.AdditionalProperties.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/additional-properties/src/_Type.Property.AdditionalProperties.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/nullable/src/_Type.Property.Nullable.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/nullable/src/_Type.Property.Nullable.csproj index 1a23a30bad..d2ead9147f 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/nullable/src/_Type.Property.Nullable.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/nullable/src/_Type.Property.Nullable.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/optionality/src/_Type.Property.Optional.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/optionality/src/_Type.Property.Optional.csproj index 9835d49eef..aac7d8b08c 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/optionality/src/_Type.Property.Optional.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/optionality/src/_Type.Property.Optional.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/value-types/src/_Type.Property.ValueTypes.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/value-types/src/_Type.Property.ValueTypes.csproj index 900e31b325..148de25ec4 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/value-types/src/_Type.Property.ValueTypes.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/property/value-types/src/_Type.Property.ValueTypes.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/scalar/src/_Type.Scalar.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/scalar/src/_Type.Scalar.csproj index 69b0bd6aab..71c54c04b7 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/scalar/src/_Type.Scalar.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/scalar/src/_Type.Scalar.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/union/src/_Type.Union.csproj b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/union/src/_Type.Union.csproj index e33609bb62..3612696d0c 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/union/src/_Type.Union.csproj +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/union/src/_Type.Union.csproj @@ -11,6 +11,6 @@ - + diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/UnbrandedTypeSpec.csproj b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/UnbrandedTypeSpec.csproj index 485bc8c973..ea25cfa6f4 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/UnbrandedTypeSpec.csproj +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/UnbrandedTypeSpec.csproj @@ -11,6 +11,6 @@ - + From 9ab01ec9699ea0bb49ac4353743b42b62bd0bab1 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:46:11 -0700 Subject: [PATCH 07/13] Handle nullable parameter types for method suppression (#4642) Fixes https://github.com/microsoft/typespec/issues/4641 --- .../src/Providers/NamedTypeSymbolProvider.cs | 198 +--------------- .../src/Providers/TypeProvider.cs | 5 +- .../Utilities/NamedTypeSymbolExtensions.cs | 36 --- .../src/Utilities/TypeSymbolExtensions.cs | 224 ++++++++++++++++++ .../ClientCustomizationTests.cs | 25 +- .../CanRemoveMethods/MockInputClient.cs | 1 + .../MockInputClient.cs | 1 + 7 files changed, 258 insertions(+), 232 deletions(-) delete mode 100644 packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Utilities/NamedTypeSymbolExtensions.cs create mode 100644 packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Utilities/TypeSymbolExtensions.cs diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/NamedTypeSymbolProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/NamedTypeSymbolProvider.cs index 92ba1d107f..dc5a15b153 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/NamedTypeSymbolProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/NamedTypeSymbolProvider.cs @@ -14,7 +14,6 @@ namespace Microsoft.Generator.CSharp.Providers { public sealed class NamedTypeSymbolProvider : TypeProvider { - private const string GlobalPrefix = "global::"; private INamedTypeSymbol _namedTypeSymbol; public NamedTypeSymbolProvider(INamedTypeSymbol namedTypeSymbol) @@ -28,7 +27,7 @@ public NamedTypeSymbolProvider(INamedTypeSymbol namedTypeSymbol) protected override string BuildName() => _namedTypeSymbol.Name; - protected override string GetNamespace() => GetFullyQualifiedNameFromDisplayString(_namedTypeSymbol.ContainingNamespace); + protected override string GetNamespace() => _namedTypeSymbol.ContainingNamespace.GetFullyQualifiedNameFromDisplayString(); public IEnumerable GetAttributes() => _namedTypeSymbol.GetAttributes(); @@ -90,7 +89,7 @@ protected override FieldProvider[] BuildFields() var fieldProvider = new FieldProvider( modifiers, - GetCSharpType(fieldSymbol.Type), + fieldSymbol.Type.GetCSharpType(), fieldSymbol.Name, this, GetSymbolXmlDoc(fieldSymbol, "summary")) @@ -112,7 +111,7 @@ protected override PropertyProvider[] BuildProperties() var propertyProvider = new PropertyProvider( GetSymbolXmlDoc(propertySymbol, "summary"), GetAccessModifier(propertySymbol.DeclaredAccessibility), - GetCSharpType(propertySymbol.Type), + propertySymbol.Type.GetCSharpType(), propertySymbol.Name, new AutoPropertyBody(propertySymbol.SetMethod is not null), this) @@ -179,7 +178,7 @@ private ParameterProvider ConvertToParameterProvider(IMethodSymbol methodSymbol, return new ParameterProvider( parameterSymbol.Name, FormattableStringHelpers.FromString(GetParameterXmlDocumentation(methodSymbol, parameterSymbol)) ?? FormattableStringHelpers.Empty, - GetCSharpType(parameterSymbol.Type)); + parameterSymbol.Type.GetCSharpType()); } private void AddAdditionalModifiers(IMethodSymbol methodSymbol, ref MethodSignatureModifiers modifiers) @@ -264,197 +263,12 @@ private static XDocument ParseXml(ISymbol docsSymbol, string xmlDocumentation) private CSharpType? GetNullableCSharpType(ITypeSymbol typeSymbol) { - var fullyQualifiedName = GetFullyQualifiedName(typeSymbol); + var fullyQualifiedName = typeSymbol.GetFullyQualifiedName(); if (fullyQualifiedName == "System.Void") { return null; } - return GetCSharpType(typeSymbol); - } - - private CSharpType GetCSharpType(ITypeSymbol typeSymbol) - { - var fullyQualifiedName = GetFullyQualifiedName(typeSymbol); - var namedTypeSymbol = typeSymbol as INamedTypeSymbol; - - Type? type = LoadFrameworkType(fullyQualifiedName); - - if (type is null) - { - return ConstructCSharpTypeFromSymbol(typeSymbol, fullyQualifiedName, namedTypeSymbol); - } - - CSharpType result = new CSharpType(type); - if (namedTypeSymbol is not null && namedTypeSymbol.IsGenericType && !result.IsNullable) - { - return result.MakeGenericType([.. namedTypeSymbol.TypeArguments.Select(GetCSharpType)]); - } - - return result; - } - - private static Type? LoadFrameworkType(string fullyQualifiedName) - { - return fullyQualifiedName switch - { - // Special case for types that would not be defined in corlib, but should still be considered framework types. - "System.BinaryData" => typeof(BinaryData), - _ => System.Type.GetType(fullyQualifiedName) - }; - } - - private CSharpType ConstructCSharpTypeFromSymbol( - ITypeSymbol typeSymbol, - string fullyQualifiedName, - INamedTypeSymbol? namedTypeSymbol) - { - var typeArg = namedTypeSymbol?.TypeArguments.FirstOrDefault(); - bool isValueType = typeSymbol.IsValueType; - bool isEnum = typeSymbol.TypeKind == TypeKind.Enum; - bool isNullable = typeSymbol.NullableAnnotation == NullableAnnotation.Annotated; - bool isNullableUnknownType = isNullable && typeArg?.TypeKind == TypeKind.Error; - string name = isNullableUnknownType ? fullyQualifiedName : typeSymbol.Name; - string[] pieces = fullyQualifiedName.Split('.'); - - // handle nullables - if (isNullable) - { - // System.Nullable`1[T] -> T - name = typeArg != null ? GetFullyQualifiedName(typeArg) : fullyQualifiedName; - pieces = name.Split('.'); - } - - return new CSharpType( - name, - string.Join('.', pieces.Take(pieces.Length - 1)), - isValueType, - isNullable, - typeSymbol.ContainingType is not null ? GetCSharpType(typeSymbol.ContainingType) : null, - namedTypeSymbol is not null && !isNullableUnknownType ? [.. namedTypeSymbol.TypeArguments.Select(GetCSharpType)] : [], - typeSymbol.DeclaredAccessibility == Accessibility.Public, - isValueType && !isEnum, - baseType: typeSymbol.BaseType is not null && typeSymbol.BaseType.TypeKind != TypeKind.Error && !isNullableUnknownType - ? GetCSharpType(typeSymbol.BaseType) - : null, - underlyingEnumType: namedTypeSymbol is not null && namedTypeSymbol.EnumUnderlyingType is not null - ? GetCSharpType(namedTypeSymbol.EnumUnderlyingType).FrameworkType - : null); - } - - private static string GetFullyQualifiedName(ITypeSymbol typeSymbol) - { - // Handle special cases for built-in types - switch (typeSymbol.SpecialType) - { - case SpecialType.System_Object: - return "System.Object"; - case SpecialType.System_Void: - return "System.Void"; - case SpecialType.System_Boolean: - return "System.Boolean"; - case SpecialType.System_Char: - return "System.Char"; - case SpecialType.System_SByte: - return "System.SByte"; - case SpecialType.System_Byte: - return "System.Byte"; - case SpecialType.System_Int16: - return "System.Int16"; - case SpecialType.System_UInt16: - return "System.UInt16"; - case SpecialType.System_Int32: - return "System.Int32"; - case SpecialType.System_UInt32: - return "System.UInt32"; - case SpecialType.System_Int64: - return "System.Int64"; - case SpecialType.System_UInt64: - return "System.UInt64"; - case SpecialType.System_Decimal: - return "System.Decimal"; - case SpecialType.System_Single: - return "System.Single"; - case SpecialType.System_Double: - return "System.Double"; - case SpecialType.System_String: - return "System.String"; - case SpecialType.System_DateTime: - return "System.DateTime"; - } - - // Handle array types - if (typeSymbol is IArrayTypeSymbol arrayTypeSymbol) - { - return GetFullyQualifiedName(arrayTypeSymbol.ElementType) + "[]"; - } - - // Handle generic types - if (typeSymbol is INamedTypeSymbol namedTypeSymbol && namedTypeSymbol.IsGenericType) - { - // Handle nullable types - if (typeSymbol.NullableAnnotation == NullableAnnotation.Annotated && !IsCollectionType(namedTypeSymbol)) - { - const string nullableTypeName = "System.Nullable"; - var argTypeSymbol = namedTypeSymbol.TypeArguments.FirstOrDefault(); - - if (argTypeSymbol != null) - { - if (argTypeSymbol.TypeKind == TypeKind.Error) - { - return GetFullyQualifiedName(argTypeSymbol); - } - - string[] typeArguments = [.. namedTypeSymbol.TypeArguments.Select(arg => "[" + GetFullyQualifiedName(arg) + "]")]; - return $"{nullableTypeName}`{namedTypeSymbol.TypeArguments.Length}[{string.Join(", ", typeArguments)}]"; - } - } - else if (namedTypeSymbol.TypeArguments.Length > 0 && !IsCollectionType(namedTypeSymbol)) - { - return GetNonNullableGenericTypeName(namedTypeSymbol); - } - - var typeNameSpan = namedTypeSymbol.ConstructedFrom.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat).AsSpan(); - var start = typeNameSpan.IndexOf(':') + 2; - var end = typeNameSpan.IndexOf('<'); - typeNameSpan = typeNameSpan.Slice(start, end - start); - return $"{typeNameSpan}`{namedTypeSymbol.TypeArguments.Length}"; - } - - // Default to fully qualified name - return GetFullyQualifiedNameFromDisplayString(typeSymbol); - } - - private static string GetNonNullableGenericTypeName(INamedTypeSymbol namedTypeSymbol) - { - string[] typeArguments = [.. namedTypeSymbol.TypeArguments.Select(GetFullyQualifiedName)]; - var fullName = namedTypeSymbol.ConstructedFrom.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - - // Remove the type arguments from the fully qualified name - var typeArgumentStartIndex = fullName.IndexOf('<'); - var genericTypeName = typeArgumentStartIndex >= 0 ? fullName.Substring(0, typeArgumentStartIndex) : fullName; - - // Remove global:: prefix - if (genericTypeName.StartsWith(GlobalPrefix, StringComparison.Ordinal)) - { - genericTypeName = genericTypeName.Substring(GlobalPrefix.Length); - } - - return $"{genericTypeName}`{namedTypeSymbol.TypeArguments.Length}[{string.Join(", ", typeArguments)}]"; - } - - private static bool IsCollectionType(INamedTypeSymbol typeSymbol) - { - // Check if the type implements IEnumerable, ICollection, or IEnumerable - return typeSymbol.AllInterfaces.Any(i => - i.OriginalDefinition.SpecialType == SpecialType.System_Collections_Generic_IEnumerable_T || - i.OriginalDefinition.SpecialType == SpecialType.System_Collections_Generic_ICollection_T || - i.OriginalDefinition.SpecialType == SpecialType.System_Collections_IEnumerable); - } - - private static string GetFullyQualifiedNameFromDisplayString(ISymbol typeSymbol) - { - var fullyQualifiedName = typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - return fullyQualifiedName.StartsWith(GlobalPrefix, StringComparison.Ordinal) ? fullyQualifiedName.Substring(GlobalPrefix.Length) : fullyQualifiedName; + return typeSymbol.GetCSharpType(); } } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs index 8cb696aec6..6c302d9140 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs @@ -424,7 +424,7 @@ private static bool IsMatch(TypeProvider enclosingType, MethodSignatureBase sign } else if (attribute.ConstructorArguments[1].Kind != TypedConstantKind.Array) { - parameterTypes = [(ISymbol?) attribute.ConstructorArguments[1].Value]; + parameterTypes = attribute.ConstructorArguments[1..].Select(a => (ISymbol?) a.Value).ToArray(); } else { @@ -437,7 +437,8 @@ private static bool IsMatch(TypeProvider enclosingType, MethodSignatureBase sign for (int i = 0; i < parameterTypes.Length; i++) { - if (parameterTypes[i]?.Name != signature.Parameters[i].Type.Name) + var parameterType = ((ITypeSymbol)parameterTypes[i]!).GetCSharpType(); + if (parameterType.Name != signature.Parameters[i].Type.Name || parameterType.IsNullable != signature.Parameters[i].Type.IsNullable) { return false; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Utilities/NamedTypeSymbolExtensions.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Utilities/NamedTypeSymbolExtensions.cs deleted file mode 100644 index 8b6c5be3e4..0000000000 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Utilities/NamedTypeSymbolExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Linq; -using Microsoft.CodeAnalysis; -using Microsoft.Generator.CSharp.Primitives; - -namespace Microsoft.Generator.CSharp -{ - internal static class NamedTypeSymbolExtensions - { - public static bool IsSameType(this INamedTypeSymbol symbol, CSharpType type) - { - if (type.IsValueType && type.IsNullable) - { - if (symbol.ConstructedFrom.SpecialType != SpecialType.System_Nullable_T) - return false; - return IsSameType((INamedTypeSymbol)symbol.TypeArguments.Single(), type.WithNullable(false)); - } - - if (symbol.ContainingNamespace.ToString() != type.Namespace || symbol.Name != type.Name || symbol.TypeArguments.Length != type.Arguments.Count) - { - return false; - } - - for (int i = 0; i < type.Arguments.Count; ++i) - { - if (!IsSameType((INamedTypeSymbol)symbol.TypeArguments[i], type.Arguments[i])) - { - return false; - } - } - return true; - } - } -} diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Utilities/TypeSymbolExtensions.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Utilities/TypeSymbolExtensions.cs new file mode 100644 index 0000000000..1efa2c8704 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Utilities/TypeSymbolExtensions.cs @@ -0,0 +1,224 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.Generator.CSharp.Primitives; + +namespace Microsoft.Generator.CSharp +{ + internal static class TypeSymbolExtensions + { + private const string GlobalPrefix = "global::"; + + public static bool IsSameType(this INamedTypeSymbol symbol, CSharpType type) + { + if (type.IsValueType && type.IsNullable) + { + if (symbol.ConstructedFrom.SpecialType != SpecialType.System_Nullable_T) + return false; + return IsSameType((INamedTypeSymbol)symbol.TypeArguments.Single(), type.WithNullable(false)); + } + + if (symbol.ContainingNamespace.ToString() != type.Namespace || symbol.Name != type.Name || symbol.TypeArguments.Length != type.Arguments.Count) + { + return false; + } + + for (int i = 0; i < type.Arguments.Count; ++i) + { + if (!IsSameType((INamedTypeSymbol)symbol.TypeArguments[i], type.Arguments[i])) + { + return false; + } + } + return true; + } + + public static CSharpType GetCSharpType(this ITypeSymbol typeSymbol) + { + var fullyQualifiedName = GetFullyQualifiedName(typeSymbol); + var namedTypeSymbol = typeSymbol as INamedTypeSymbol; + + Type? type = LoadFrameworkType(fullyQualifiedName); + + if (type is null) + { + return ConstructCSharpTypeFromSymbol(typeSymbol, fullyQualifiedName, namedTypeSymbol); + } + + CSharpType result = new CSharpType(type); + if (namedTypeSymbol is not null && namedTypeSymbol.IsGenericType && !result.IsNullable) + { + return result.MakeGenericType([.. namedTypeSymbol.TypeArguments.Select(GetCSharpType)]); + } + + return result; + } + + public static string GetFullyQualifiedName(this ITypeSymbol typeSymbol) + { + // Handle special cases for built-in types + switch (typeSymbol.SpecialType) + { + case SpecialType.System_Object: + return "System.Object"; + case SpecialType.System_Void: + return "System.Void"; + case SpecialType.System_Boolean: + return "System.Boolean"; + case SpecialType.System_Char: + return "System.Char"; + case SpecialType.System_SByte: + return "System.SByte"; + case SpecialType.System_Byte: + return "System.Byte"; + case SpecialType.System_Int16: + return "System.Int16"; + case SpecialType.System_UInt16: + return "System.UInt16"; + case SpecialType.System_Int32: + return "System.Int32"; + case SpecialType.System_UInt32: + return "System.UInt32"; + case SpecialType.System_Int64: + return "System.Int64"; + case SpecialType.System_UInt64: + return "System.UInt64"; + case SpecialType.System_Decimal: + return "System.Decimal"; + case SpecialType.System_Single: + return "System.Single"; + case SpecialType.System_Double: + return "System.Double"; + case SpecialType.System_String: + return "System.String"; + case SpecialType.System_DateTime: + return "System.DateTime"; + } + + // Handle array types + if (typeSymbol is IArrayTypeSymbol arrayTypeSymbol) + { + return GetFullyQualifiedName(arrayTypeSymbol.ElementType) + "[]"; + } + + // Handle generic types + if (typeSymbol is INamedTypeSymbol namedTypeSymbol && namedTypeSymbol.IsGenericType) + { + // Handle nullable types + if (typeSymbol.NullableAnnotation == NullableAnnotation.Annotated && !IsCollectionType(namedTypeSymbol)) + { + const string nullableTypeName = "System.Nullable"; + var argTypeSymbol = namedTypeSymbol.TypeArguments.FirstOrDefault(); + + if (argTypeSymbol != null) + { + if (argTypeSymbol.TypeKind == TypeKind.Error) + { + return GetFullyQualifiedName(argTypeSymbol); + } + + string[] typeArguments = [.. namedTypeSymbol.TypeArguments.Select(arg => "[" + GetFullyQualifiedName(arg) + "]")]; + return $"{nullableTypeName}`{namedTypeSymbol.TypeArguments.Length}[{string.Join(", ", typeArguments)}]"; + } + } + else if (namedTypeSymbol.TypeArguments.Length > 0 && !IsCollectionType(namedTypeSymbol)) + { + return GetNonNullableGenericTypeName(namedTypeSymbol); + } + + var typeNameSpan = namedTypeSymbol.ConstructedFrom.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat).AsSpan(); + var start = typeNameSpan.IndexOf(':') + 2; + var end = typeNameSpan.IndexOf('<'); + typeNameSpan = typeNameSpan.Slice(start, end - start); + return $"{typeNameSpan}`{namedTypeSymbol.TypeArguments.Length}"; + } + + // Default to fully qualified name + return GetFullyQualifiedNameFromDisplayString(typeSymbol); + } + + public static string GetFullyQualifiedNameFromDisplayString(this ISymbol typeSymbol) + { + var fullyQualifiedName = typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); + return fullyQualifiedName.StartsWith(GlobalPrefix, StringComparison.Ordinal) ? fullyQualifiedName.Substring(GlobalPrefix.Length) : fullyQualifiedName; + } + + private static Type? LoadFrameworkType(string fullyQualifiedName) + { + return fullyQualifiedName switch + { + // Special case for types that would not be defined in corlib, but should still be considered framework types. + "System.BinaryData" => typeof(BinaryData), + _ => System.Type.GetType(fullyQualifiedName) + }; + } + + private static CSharpType ConstructCSharpTypeFromSymbol( + ITypeSymbol typeSymbol, + string fullyQualifiedName, + INamedTypeSymbol? namedTypeSymbol) + { + var typeArg = namedTypeSymbol?.TypeArguments.FirstOrDefault(); + bool isValueType = typeSymbol.IsValueType; + bool isEnum = typeSymbol.TypeKind == TypeKind.Enum; + bool isNullable = typeSymbol.NullableAnnotation == NullableAnnotation.Annotated; + bool isNullableUnknownType = isNullable && typeArg?.TypeKind == TypeKind.Error; + string name = isNullableUnknownType ? fullyQualifiedName : typeSymbol.Name; + string[] pieces = fullyQualifiedName.Split('.'); + + // handle nullables + if (isNullable) + { + // System.Nullable`1[T] -> T + name = typeArg != null ? GetFullyQualifiedName(typeArg) : fullyQualifiedName; + pieces = name.Split('.'); + } + + return new CSharpType( + name, + string.Join('.', pieces.Take(pieces.Length - 1)), + isValueType, + isNullable, + typeSymbol.ContainingType is not null ? GetCSharpType(typeSymbol.ContainingType) : null, + namedTypeSymbol is not null && !isNullableUnknownType ? [.. namedTypeSymbol.TypeArguments.Select(GetCSharpType)] : [], + typeSymbol.DeclaredAccessibility == Accessibility.Public, + isValueType && !isEnum, + baseType: typeSymbol.BaseType is not null && typeSymbol.BaseType.TypeKind != TypeKind.Error && !isNullableUnknownType + ? GetCSharpType(typeSymbol.BaseType) + : null, + underlyingEnumType: namedTypeSymbol is not null && namedTypeSymbol.EnumUnderlyingType is not null + ? GetCSharpType(namedTypeSymbol.EnumUnderlyingType).FrameworkType + : null); + } + + private static bool IsCollectionType(INamedTypeSymbol typeSymbol) + { + // Check if the type implements IEnumerable, ICollection, or IEnumerable + return typeSymbol.AllInterfaces.Any(i => + i.OriginalDefinition.SpecialType == SpecialType.System_Collections_Generic_IEnumerable_T || + i.OriginalDefinition.SpecialType == SpecialType.System_Collections_Generic_ICollection_T || + i.OriginalDefinition.SpecialType == SpecialType.System_Collections_IEnumerable); + } + + private static string GetNonNullableGenericTypeName(INamedTypeSymbol namedTypeSymbol) + { + string[] typeArguments = [.. namedTypeSymbol.TypeArguments.Select(GetFullyQualifiedName)]; + var fullName = namedTypeSymbol.ConstructedFrom.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); + + // Remove the type arguments from the fully qualified name + var typeArgumentStartIndex = fullName.IndexOf('<'); + var genericTypeName = typeArgumentStartIndex >= 0 ? fullName.Substring(0, typeArgumentStartIndex) : fullName; + + // Remove global:: prefix + if (genericTypeName.StartsWith(GlobalPrefix, StringComparison.Ordinal)) + { + genericTypeName = genericTypeName.Substring(GlobalPrefix.Length); + } + + return $"{genericTypeName}`{namedTypeSymbol.TypeArguments.Length}[{string.Join(", ", typeArguments)}]"; + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs index a5b9143661..078591e3cd 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs @@ -46,7 +46,17 @@ public async Task CanRemoveMethods() [ new ParameterProvider("param1", $"", typeof(string)), new ParameterProvider("param2", $"", typeof(int))]), - Snippet.ThrowExpression(Snippet.Null), client) + Snippet.ThrowExpression(Snippet.Null), client), + new MethodProvider(new MethodSignature( + "Method4", + $"", + MethodSignatureModifiers.Public, + null, + $"", + [ + new ParameterProvider("param1", $"", typeof(string)), + new ParameterProvider("param2", $"", typeof(int?))]), + Snippet.ThrowExpression(Snippet.Null), client), }; client.MethodProviders = methods; @@ -97,6 +107,17 @@ public async Task DoesNotRemoveMethodsThatDoNotMatch() [ new ParameterProvider("param1", $"", typeof(string)), new ParameterProvider("param2", $"", typeof(int))]), + Snippet.ThrowExpression(Snippet.Null), client), + // Nullability of one of the parameters doesn't match + new MethodProvider(new MethodSignature( + "Method4", + $"", + MethodSignatureModifiers.Public, + null, + $"", + [ + new ParameterProvider("param1", $"", typeof(string)), + new ParameterProvider("param2", $"", typeof(int?))]), Snippet.ThrowExpression(Snippet.Null), client) }; @@ -109,7 +130,7 @@ public async Task DoesNotRemoveMethodsThatDoNotMatch() var csharpGen = new CSharpGen(); await csharpGen.ExecuteAsync(); - Assert.AreEqual(3, plugin.Object.OutputLibrary.TypeProviders.Single(t => t.Name == "MockInputClient").Methods.Count); + Assert.AreEqual(4, plugin.Object.OutputLibrary.TypeProviders.Single(t => t.Name == "MockInputClient").Methods.Count); } [Test] diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/CanRemoveMethods/MockInputClient.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/CanRemoveMethods/MockInputClient.cs index 65e9152519..6f648fee0a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/CanRemoveMethods/MockInputClient.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/CanRemoveMethods/MockInputClient.cs @@ -6,6 +6,7 @@ namespace Sample; [CodeGenSuppress("Method1")] [CodeGenSuppress("Method2", typeof(bool)] [CodeGenSuppress("Method3", typeof(string), typeof(int))] +[CodeGenSuppress("Method4", typeof(string), typeof(int?))] public partial class MockInputClient { } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/DoesNotRemoveMethodsThatDoNotMatch/MockInputClient.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/DoesNotRemoveMethodsThatDoNotMatch/MockInputClient.cs index 550401ac55..a33808a7ce 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/DoesNotRemoveMethodsThatDoNotMatch/MockInputClient.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/DoesNotRemoveMethodsThatDoNotMatch/MockInputClient.cs @@ -5,6 +5,7 @@ namespace Sample; [CodeGenSuppress("Method1")] [CodeGenSuppress("Method2", typeof(bool)] [CodeGenSuppress("Method3", typeof(string), typeof(int), typeof(bool))] +[CodeGenSuppress("Method4", typeof(string), typeof(int)] public partial class MockInputClient { } From 8f50ec66a1c0e267f572790fc5cef8c28240f495 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:18:54 -0700 Subject: [PATCH 08/13] Support customizing model factory accessibility (#4643) Fixes https://github.com/microsoft/typespec/issues/4634 --- .../src/Providers/ClientOptionsProvider.cs | 2 - .../src/Providers/ClientProvider.cs | 2 - .../src/Providers/RestClientProvider.cs | 2 - .../src/PostProcessing/PostProcessor.cs | 13 +++-- .../src/Providers/ExtensibleEnumProvider.cs | 7 +-- .../src/Providers/FixedEnumProvider.cs | 7 +-- .../src/Providers/ModelFactoryProvider.cs | 2 +- .../src/Providers/ModelProvider.cs | 2 +- .../src/Providers/TypeProvider.cs | 7 ++- .../ModelFactoriesCustomizationTests.cs | 47 +++++++++++++++++++ .../SampleNamespaceModelFactory.cs | 9 ++++ .../ClientCustomizationTests.cs | 18 +++---- 12 files changed, 83 insertions(+), 35 deletions(-) create mode 100644 packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/TestData/ModelFactoriesCustomizationTests/CanChangeAccessibilityOfModelFactory/SampleNamespaceModelFactory.cs diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ClientOptionsProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ClientOptionsProvider.cs index 6c2a811561..a936f139f3 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ClientOptionsProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ClientOptionsProvider.cs @@ -145,7 +145,5 @@ protected override PropertyProvider[] BuildProperties() return [.. properties]; } - - protected override TypeSignatureModifiers GetDeclarationModifiers() => GetCustomCodeModifiers(); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ClientProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ClientProvider.cs index 246aea4b10..cc3cfbb3e0 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ClientProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ClientProvider.cs @@ -413,8 +413,6 @@ protected override MethodProvider[] BuildMethods() return [.. methods]; } - protected override TypeSignatureModifiers GetDeclarationModifiers() => GetCustomCodeModifiers(); - private ParameterProvider BuildClientEndpointParameter() { var endpointParam = _inputClient.Parameters.FirstOrDefault(p => p.IsEndpoint); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/RestClientProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/RestClientProvider.cs index 9f0b5acd36..ca326c3f89 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/RestClientProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/RestClientProvider.cs @@ -121,8 +121,6 @@ protected override MethodProvider[] BuildMethods() return [.. methods]; } - protected override TypeSignatureModifiers GetDeclarationModifiers() => GetCustomCodeModifiers(); - private bool IsCreateRequest(MethodProvider method) { var span = method.Signature.Name.AsSpan(); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/PostProcessing/PostProcessor.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/PostProcessing/PostProcessor.cs index 96167f06c8..47044a2dcb 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/PostProcessing/PostProcessor.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/PostProcessing/PostProcessor.cs @@ -176,13 +176,16 @@ private async Task RemoveMethodsFromModelFactoryAsync(Project project, // find the GENERATED document of model factory (we may have the customized document of this for overloads) Document? modelFactoryGeneratedDocument = null; // the nodes corresponding to the model factory symbol has never been changed therefore the nodes inside the cache are still usable - foreach (var declarationNode in definitions.DeclaredNodesCache[modelFactorySymbol]) + if (definitions.DeclaredNodesCache.TryGetValue(modelFactorySymbol, out var nodes)) { - var document = project.GetDocument(declarationNode.SyntaxTree); - if (document != null && GeneratedCodeWorkspace.IsGeneratedDocument(document)) + foreach (var declarationNode in nodes) { - modelFactoryGeneratedDocument = document; - break; + var document = project.GetDocument(declarationNode.SyntaxTree); + if (document != null && GeneratedCodeWorkspace.IsGeneratedDocument(document)) + { + modelFactoryGeneratedDocument = document; + break; + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ExtensibleEnumProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ExtensibleEnumProvider.cs index 26d7a7ee38..28d6386a1c 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ExtensibleEnumProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ExtensibleEnumProvider.cs @@ -26,13 +26,8 @@ internal ExtensibleEnumProvider(InputEnumType input, TypeProvider? declaringType _allowedValues = input.Values; // extensible enums are implemented as readonly structs _modifiers = TypeSignatureModifiers.Partial | TypeSignatureModifiers.ReadOnly | TypeSignatureModifiers.Struct; - var customCodeModifiers = GetCustomCodeModifiers(); - if (customCodeModifiers != TypeSignatureModifiers.None) - { - _modifiers |= customCodeModifiers; - } - else if (input.Accessibility == "internal") + if (input.Accessibility == "internal") { _modifiers |= TypeSignatureModifiers.Internal; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/FixedEnumProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/FixedEnumProvider.cs index 4a8e192839..ca8653c45f 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/FixedEnumProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/FixedEnumProvider.cs @@ -27,12 +27,7 @@ internal FixedEnumProvider(InputEnumType input, TypeProvider? declaringType) : b // fixed enums are implemented by enum in C# _modifiers = TypeSignatureModifiers.Enum; - var customCodeModifiers = GetCustomCodeModifiers(); - if (customCodeModifiers != TypeSignatureModifiers.None) - { - _modifiers |= customCodeModifiers; - } - else if (input.Accessibility == "internal") + if (input.Accessibility == "internal") { _modifiers |= TypeSignatureModifiers.Internal; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelFactoryProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelFactoryProvider.cs index 14f83c1a7a..215f320dd7 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelFactoryProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelFactoryProvider.cs @@ -52,7 +52,7 @@ protected override string BuildName() protected override string BuildRelativeFilePath() => Path.Combine("src", "Generated", $"{Name}.cs"); protected override TypeSignatureModifiers GetDeclarationModifiers() - => TypeSignatureModifiers.Static | TypeSignatureModifiers.Public | TypeSignatureModifiers.Class | TypeSignatureModifiers.Partial; + => TypeSignatureModifiers.Public | TypeSignatureModifiers.Static | TypeSignatureModifiers.Partial | TypeSignatureModifiers.Class; protected override string GetNamespace() => CodeModelPlugin.Instance.Configuration.ModelNamespace; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelProvider.cs index 7828063ac7..030367ebff 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/ModelProvider.cs @@ -104,7 +104,7 @@ protected override TypeProvider[] BuildSerializationProviders() protected override TypeSignatureModifiers GetDeclarationModifiers() { - var customCodeModifiers = GetCustomCodeModifiers(); + var customCodeModifiers = CustomCodeView?.DeclarationModifiers ?? TypeSignatureModifiers.None; var isStruct = false; // the information of if this model should be a struct comes from two sources: // 1. the customied code diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs index 6c302d9140..8ae0df855e 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs @@ -82,11 +82,14 @@ public TypeSignatureModifiers DeclarationModifiers protected virtual TypeSignatureModifiers GetDeclarationModifiers() => TypeSignatureModifiers.None; - protected TypeSignatureModifiers GetCustomCodeModifiers() => CustomCodeView?.DeclarationModifiers ?? TypeSignatureModifiers.None; - private TypeSignatureModifiers GetDeclarationModifiersInternal() { var modifiers = GetDeclarationModifiers(); + var customModifiers = CustomCodeView?.DeclarationModifiers ?? TypeSignatureModifiers.None; + if (customModifiers != TypeSignatureModifiers.None) + { + modifiers |= customModifiers; + } // we default to public when no accessibility modifier is provided if (!modifiers.HasFlag(TypeSignatureModifiers.Internal) && !modifiers.HasFlag(TypeSignatureModifiers.Public) && !modifiers.HasFlag(TypeSignatureModifiers.Private)) { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/ModelFactoriesCustomizationTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/ModelFactoriesCustomizationTests.cs index 2d7e173abb..da8a90375b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/ModelFactoriesCustomizationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/ModelFactoriesCustomizationTests.cs @@ -3,7 +3,9 @@ using System.Linq; using System.Threading.Tasks; +using Microsoft.CodeAnalysis; using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Primitives; using Microsoft.Generator.CSharp.Providers; using Microsoft.Generator.CSharp.Tests.Common; using NUnit.Framework; @@ -37,6 +39,10 @@ public async Task CanReplaceModelMethod() var modelFactory = plugin.Object.OutputLibrary.TypeProviders.SingleOrDefault(t => t is ModelFactoryProvider); Assert.IsNotNull(modelFactory); + // The model factory should be public + Assert.IsTrue(modelFactory!.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Public)); + ValidateModelFactoryCommon(modelFactory); + // The model factory method should be replaced var modelFactoryMethods = modelFactory!.Methods; Assert.AreEqual(1, modelFactoryMethods.Count); @@ -71,9 +77,50 @@ public async Task DoesNotReplaceMethodIfNotCustomized() var modelFactory = plugin.Object.OutputLibrary.TypeProviders.SingleOrDefault(t => t is ModelFactoryProvider); Assert.IsNotNull(modelFactory); + // The model factory should be public + Assert.IsTrue(modelFactory!.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Public)); + ValidateModelFactoryCommon(modelFactory); + // The model factory method should not be replaced var modelFactoryMethods = modelFactory!.Methods; Assert.AreEqual(1, modelFactoryMethods.Count); } + + private static void ValidateModelFactoryCommon(TypeProvider modelFactory) + { + Assert.IsTrue(modelFactory!.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Static)); + Assert.IsTrue(modelFactory!.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Partial)); + Assert.IsTrue(modelFactory!.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Class)); + } + + [Test] + public async Task CanChangeAccessibilityOfModelFactory() + { + var plugin = await MockHelpers.LoadMockPluginAsync( + inputModelTypes: [ + InputFactory.Model( + "mockInputModel", + properties: + [ + InputFactory.Property("Prop1", InputPrimitiveType.String), + InputFactory.Property("OptionalBool", InputPrimitiveType.Boolean, isRequired: false) + ]), + InputFactory.Model( + "otherModel", + properties: [InputFactory.Property("Prop2", InputPrimitiveType.String)]), + ], + compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); + var csharpGen = new CSharpGen(); + + await csharpGen.ExecuteAsync(); + + // Find the model factory provider + var modelFactory = plugin.Object.OutputLibrary.TypeProviders.SingleOrDefault(t => t is ModelFactoryProvider); + Assert.IsNotNull(modelFactory); + + // The model factory should be internal + Assert.IsTrue(modelFactory!.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Internal)); + ValidateModelFactoryCommon(modelFactory); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/TestData/ModelFactoriesCustomizationTests/CanChangeAccessibilityOfModelFactory/SampleNamespaceModelFactory.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/TestData/ModelFactoriesCustomizationTests/CanChangeAccessibilityOfModelFactory/SampleNamespaceModelFactory.cs new file mode 100644 index 0000000000..30350730fe --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelFactories/TestData/ModelFactoriesCustomizationTests/CanChangeAccessibilityOfModelFactory/SampleNamespaceModelFactory.cs @@ -0,0 +1,9 @@ +using Microsoft.Generator.CSharp.Customization; +using System; + +namespace Sample.Models +{ + internal static partial class SampleNamespaceModelFactory + { + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs index 078591e3cd..2b4c8bca50 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs @@ -17,6 +17,11 @@ public class ClientCustomizationTests public async Task CanRemoveMethods() { var client = new ClientTypeProvider(); + var outputLibrary = new ClientOutputLibrary(client); + var plugin = await MockHelpers.LoadMockPluginAsync( + createOutputLibrary: () => outputLibrary, + compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); + var methods = new[] { new MethodProvider(new MethodSignature( @@ -60,11 +65,7 @@ public async Task CanRemoveMethods() }; client.MethodProviders = methods; - var outputLibrary = new ClientOutputLibrary(client); - var plugin = await MockHelpers.LoadMockPluginAsync( - createOutputLibrary: () => outputLibrary, - compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); var csharpGen = new CSharpGen(); await csharpGen.ExecuteAsync(); @@ -75,6 +76,11 @@ public async Task CanRemoveMethods() public async Task DoesNotRemoveMethodsThatDoNotMatch() { var client = new ClientTypeProvider(); + var outputLibrary = new ClientOutputLibrary(client); + var plugin = await MockHelpers.LoadMockPluginAsync( + createOutputLibrary: () => outputLibrary, + compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); + var methods = new[] { // Method name doesn't match @@ -122,11 +128,7 @@ public async Task DoesNotRemoveMethodsThatDoNotMatch() }; client.MethodProviders = methods; - var outputLibrary = new ClientOutputLibrary(client); - var plugin = await MockHelpers.LoadMockPluginAsync( - createOutputLibrary: () => outputLibrary, - compilation: async () => await Helpers.GetCompilationFromDirectoryAsync()); var csharpGen = new CSharpGen(); await csharpGen.ExecuteAsync(); From 767ee82916d370b57c8a1d28a9f37823955dec84 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 9 Oct 2024 11:25:58 -0700 Subject: [PATCH 09/13] Fix virtual path playground (#4656) Only changed the entrypoint also needed for the output path --- .../fix-virtual-path-playground-2024-9-9-10-21-58.md | 6 ++++++ .../fix-virtual-path-playground-2024-9-9-10-47-42.md | 6 ++++++ packages/playground/src/react/playground.tsx | 6 +++--- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .chronus/changes/fix-virtual-path-playground-2024-9-9-10-21-58.md create mode 100644 .chronus/changes/fix-virtual-path-playground-2024-9-9-10-47-42.md diff --git a/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-21-58.md b/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-21-58.md new file mode 100644 index 0000000000..f1073d0f71 --- /dev/null +++ b/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-21-58.md @@ -0,0 +1,6 @@ +--- +changeKind: internal +packages: + - "@typespec/playground" +--- + diff --git a/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-47-42.md b/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-47-42.md new file mode 100644 index 0000000000..f441bba5f0 --- /dev/null +++ b/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-47-42.md @@ -0,0 +1,6 @@ +--- +changeKind: internal +packages: + - "@typespec/compiler" +--- + diff --git a/packages/playground/src/react/playground.tsx b/packages/playground/src/react/playground.tsx index 798b6fbf29..8356f815f0 100644 --- a/packages/playground/src/react/playground.tsx +++ b/packages/playground/src/react/playground.tsx @@ -332,7 +332,7 @@ const verticalPaneSizesConst = { collapsed: [undefined, 30], expanded: [undefined, 200], }; -const outputDir = "./tsp-output"; +const outputDir = resolveVirtualPath("tsp-output"); async function compile( host: BrowserHost, @@ -350,10 +350,10 @@ async function compile( ...options.options, [selectedEmitter]: { ...options.options?.[selectedEmitter], - "emitter-output-dir": "tsp-output", + "emitter-output-dir": outputDir, }, }, - outputDir: "tsp-output", + outputDir, emit: selectedEmitter ? [selectedEmitter] : [], }); const outputFiles = await findOutputFiles(host); From 57a7e11a86858d05c615229beb62637bc91dcbdb Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:26:33 -0700 Subject: [PATCH 10/13] Make metadatareferences additive (#4646) Fixes https://github.com/microsoft/typespec/issues/4645 --- .../src/StubLibraryPlugin.cs | 1 + .../src/ClientModelPlugin.cs | 11 ++++------- .../src/CodeModelPlugin.cs | 12 +++++++++--- .../test/CSharpGenTests.cs | 1 - 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel.StubLibrary/src/StubLibraryPlugin.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel.StubLibrary/src/StubLibraryPlugin.cs index 0508d5b7ce..7d57607a53 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel.StubLibrary/src/StubLibraryPlugin.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel.StubLibrary/src/StubLibraryPlugin.cs @@ -14,6 +14,7 @@ public StubLibraryPlugin(GeneratorContext context) : base(context) { } public override void Configure() { + base.Configure(); AddVisitor(new StubLibraryVisitor()); } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/ClientModelPlugin.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/ClientModelPlugin.cs index 18100bbb51..29bd71d2e1 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/ClientModelPlugin.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/ClientModelPlugin.cs @@ -22,13 +22,6 @@ public class ClientModelPlugin : CodeModelPlugin public override ScmTypeFactory TypeFactory { get; } - public override IReadOnlyList AdditionalMetadataReferences => - [ - MetadataReference.CreateFromFile(typeof(ClientResult).Assembly.Location), - MetadataReference.CreateFromFile(typeof(BinaryData).Assembly.Location), - MetadataReference.CreateFromFile(typeof(JsonSerializer).Assembly.Location) - ]; - [ImportingConstructor] public ClientModelPlugin(GeneratorContext context) : base(context) @@ -39,7 +32,11 @@ public ClientModelPlugin(GeneratorContext context) public override void Configure() { + base.Configure(); AddVisitor(new DefaultScmLibraryVisitor()); + AddMetadataReference(MetadataReference.CreateFromFile(typeof(ClientResult).Assembly.Location)); + AddMetadataReference(MetadataReference.CreateFromFile(typeof(BinaryData).Assembly.Location)); + AddMetadataReference(MetadataReference.CreateFromFile(typeof(JsonSerializer).Assembly.Location)); } } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CodeModelPlugin.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CodeModelPlugin.cs index b912fb1404..f71e1cfa84 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CodeModelPlugin.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CodeModelPlugin.cs @@ -22,6 +22,7 @@ namespace Microsoft.Generator.CSharp public abstract class CodeModelPlugin { private List _visitors = []; + private List _additionalMetadataReferences = []; private static CodeModelPlugin? _instance; internal static CodeModelPlugin Instance { @@ -37,7 +38,7 @@ internal static CodeModelPlugin Instance public Configuration Configuration { get; } - public virtual IReadOnlyList Visitors => _visitors; + public IReadOnlyList Visitors => _visitors; [ImportingConstructor] public CodeModelPlugin(GeneratorContext context) @@ -64,17 +65,22 @@ protected CodeModelPlugin() public virtual OutputLibrary OutputLibrary { get; } = new(); public virtual InputLibrary InputLibrary => _inputLibrary.Value; public virtual TypeProviderWriter GetWriter(TypeProvider provider) => new(provider); - public virtual IReadOnlyList AdditionalMetadataReferences => []; + public IReadOnlyList AdditionalMetadataReferences => _additionalMetadataReferences; public virtual void Configure() { } - public virtual void AddVisitor(LibraryVisitor visitor) + public void AddVisitor(LibraryVisitor visitor) { _visitors.Add(visitor); } + public void AddMetadataReference(MetadataReference reference) + { + _additionalMetadataReferences.Add(reference); + } + private SourceInputModel? _sourceInputModel; internal async Task InitializeSourceInputModelAsync() { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/CSharpGenTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/CSharpGenTests.cs index 10d7e42572..6b977fd7dd 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/CSharpGenTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/CSharpGenTests.cs @@ -31,7 +31,6 @@ public void VisitorsAreVisited() var csharpGen = new CSharpGen(); Assert.DoesNotThrowAsync(async () => await csharpGen.ExecuteAsync()); - mockPlugin.Verify(m => m.Visitors, Times.Once); mockVisitor.Verify(m => m.Visit(mockPlugin.Object.OutputLibrary), Times.Once); } } From be9f9eb080b0421575121fe69c3f36234b854167 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:52:18 -0700 Subject: [PATCH 11/13] Fix parameter matching for reference types where the CSharpType is nullable (#4659) --- .../src/Providers/TypeProvider.cs | 5 ++++- .../ModelProviders/ClientCustomizationTests.cs | 11 +++++++++++ .../CanRemoveMethods/MockInputClient.cs | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs index 8ae0df855e..996b686736 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/TypeProvider.cs @@ -441,7 +441,10 @@ private static bool IsMatch(TypeProvider enclosingType, MethodSignatureBase sign for (int i = 0; i < parameterTypes.Length; i++) { var parameterType = ((ITypeSymbol)parameterTypes[i]!).GetCSharpType(); - if (parameterType.Name != signature.Parameters[i].Type.Name || parameterType.IsNullable != signature.Parameters[i].Type.IsNullable) + // we ignore nullability for reference types as these are generated the same regardless of nullability + // TODO - switch to using CSharpType.Equals once https://github.com/microsoft/typespec/issues/4624 is fixed. + if (parameterType.Name != signature.Parameters[i].Type.Name || + (parameterType.IsValueType && parameterType.IsNullable != signature.Parameters[i].Type.IsNullable)) { return false; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs index 2b4c8bca50..9cfdb9849b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/ClientCustomizationTests.cs @@ -62,6 +62,17 @@ public async Task CanRemoveMethods() new ParameterProvider("param1", $"", typeof(string)), new ParameterProvider("param2", $"", typeof(int?))]), Snippet.ThrowExpression(Snippet.Null), client), + new MethodProvider(new MethodSignature( + "Method5", + $"", + MethodSignatureModifiers.Public, + null, + $"", + [ + // nullability should be ignored for reference types + new ParameterProvider("param1", $"", new CSharpType(typeof(string), isNullable: true)) + ]), + Snippet.ThrowExpression(Snippet.Null), client), }; client.MethodProviders = methods; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/CanRemoveMethods/MockInputClient.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/CanRemoveMethods/MockInputClient.cs index 6f648fee0a..a04f1e42c2 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/CanRemoveMethods/MockInputClient.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/ModelProviders/TestData/ClientCustomizationTests/CanRemoveMethods/MockInputClient.cs @@ -7,6 +7,7 @@ namespace Sample; [CodeGenSuppress("Method2", typeof(bool)] [CodeGenSuppress("Method3", typeof(string), typeof(int))] [CodeGenSuppress("Method4", typeof(string), typeof(int?))] +[CodeGenSuppress("Method5", typeof(string))] public partial class MockInputClient { } From 29c0082df30abf50262dc8bfd304622453973a12 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 9 Oct 2024 14:27:28 -0700 Subject: [PATCH 12/13] Bump version for release 0.61.0 (#4661) --- .../changes/1ds-mc1-ms0-2024-8-13-14-14-2.md | 7 -- ...InfoUnallowKeyChecker-2024-8-24-11-6-11.md | 7 -- ...manticWalkerExitFixes-2024-9-9-10-27-23.md | 7 -- .../add-streaming-2024-8-25-11-52-49.md | 7 -- .../add-streaming-2024-8-25-11-53-37.md | 7 -- .../add-streaming-2024-8-25-11-54-27.md | 7 -- .../add-streaming-2024-8-25-11-56-3.md | 7 -- .../add-streaming-2024-8-25-11-56-36.md | 7 -- ...d-ScalarDefaultValue-2024-8-12-15-34-32.md | 7 -- .../config-invalid-name-2024-8-25-19-8-41.md | 7 -- ...shalling-new-default-2024-8-23-14-22-52.md | 15 --- ...rshalling-new-default-2024-8-23-21-44-3.md | 8 -- .../diagnostic-url-2024-8-13-19-59-26.md | 8 -- .../feature-mutators-2024-7-28-15-59-14.md | 7 -- ...checking-file-changed-2024-9-4-21-56-58.md | 8 -- ...enum-in-union-example-2024-8-17-18-25-2.md | 8 -- .../fix-examples-const-2024-8-30-17-28-17.md | 8 -- ...xamples-encoded-name-2024-8-26-12-52-20.md | 7 -- .../fix-invalid-or-2024-8-18-21-5-24.md | 9 -- ...c-leading-0-mulitple-2024-8-24-10-20-50.md | 7 -- ...screen-and-formatter-2024-8-26-12-35-15.md | 6 - ...roject-source-models-2024-8-13-15-15-44.md | 7 -- .../fix-server-file-cache-2024-8-18-11-4-8.md | 7 -- ...rtual-path-playground-2024-9-9-10-21-58.md | 6 - ...rtual-path-playground-2024-9-9-10-47-42.md | 6 - .../fix-watch-config-2024-8-27-22-7-45.md | 8 -- ...mat-trailling-commas-2024-8-16-18-56-35.md | 26 ---- .../json-schema-examples-2024-8-13-16-5-45.md | 7 -- .chronus/changes/main-2024-8-4-15-6-54.md | 7 -- ...ctor-packagejson-type-2024-9-3-17-20-34.md | 8 -- ...actor-state-accessor-2024-8-17-15-11-51.md | 7 -- ...actor-state-accessor-2024-8-17-21-56-42.md | 8 -- ...resolve-module-exports-2024-9-4-18-32-9.md | 19 --- ...esolve-module-exports-2024-9-4-22-21-14.md | 8 -- ...le-base-nested-config-2024-8-25-19-8-41.md | 7 -- ...rmsOfServiceUrlCheck-2024-8-23-12-59-15.md | 7 -- ...grade-deps-sep-2024-2-2024-8-25-9-32-48.md | 25 ---- ...upgrade-deps-sep-2024-2024-8-13-0-37-48.md | 27 ----- ...pgrade-monaco-editor-2024-8-25-21-58-44.md | 8 -- .../use-shell-for-cmd-2024-8-13-11-39-59.md | 7 -- .../changes/vscode-web-2024-8-23-20-15-22.md | 8 -- .../changes/vscode-web-2024-8-23-21-44-3.md | 8 -- packages/bundler/CHANGELOG.md | 7 ++ packages/bundler/package.json | 2 +- packages/compiler/CHANGELOG.md | 51 ++++++++ packages/compiler/package.json | 2 +- packages/compiler/templates/scaffolding.json | 8 +- packages/eslint-plugin-typespec/CHANGELOG.md | 7 ++ packages/eslint-plugin-typespec/package.json | 2 +- packages/events/CHANGELOG.md | 7 ++ packages/events/package.json | 2 +- packages/html-program-viewer/CHANGELOG.md | 7 ++ packages/html-program-viewer/package.json | 2 +- packages/http-server-csharp/CHANGELOG.md | 7 ++ packages/http-server-csharp/package.json | 2 +- packages/http-server-javascript/CHANGELOG.md | 7 ++ packages/http-server-javascript/package.json | 2 +- packages/http/CHANGELOG.md | 11 ++ packages/http/package.json | 2 +- packages/internal-build-utils/CHANGELOG.md | 11 ++ packages/internal-build-utils/package.json | 2 +- packages/json-schema/CHANGELOG.md | 11 ++ packages/json-schema/package.json | 2 +- packages/library-linter/CHANGELOG.md | 7 ++ packages/library-linter/package.json | 2 +- packages/openapi/CHANGELOG.md | 12 ++ packages/openapi/package.json | 2 +- packages/openapi3/CHANGELOG.md | 11 ++ packages/openapi3/package.json | 2 +- packages/playground/CHANGELOG.md | 15 +++ packages/playground/package.json | 2 +- .../prettier-plugin-typespec/CHANGELOG.md | 7 ++ .../prettier-plugin-typespec/package.json | 2 +- packages/protobuf/CHANGELOG.md | 7 ++ packages/protobuf/package.json | 2 +- packages/rest/CHANGELOG.md | 7 ++ packages/rest/package.json | 2 +- packages/sse/CHANGELOG.md | 7 ++ packages/sse/package.json | 2 +- packages/streams/CHANGELOG.md | 7 ++ packages/streams/package.json | 2 +- packages/tmlanguage-generator/CHANGELOG.md | 7 ++ packages/tmlanguage-generator/package.json | 2 +- packages/typespec-vs/CHANGELOG.md | 4 + packages/typespec-vs/package.json | 2 +- packages/typespec-vscode/CHANGELOG.md | 16 +++ packages/typespec-vscode/package.json | 2 +- packages/versioning/CHANGELOG.md | 7 ++ packages/versioning/package.json | 2 +- packages/website/playground-versions.json | 1 + .../reference/js-api/variables/$lib.md | 2 - .../protobuf/reference/js-api/index.md | 2 +- .../extending-typespec/basics.md | 32 ++--- .../emitter-metadata-handling.md | 2 +- .../extending-typespec/emitters-basics.md | 3 +- .../handbook/configuration/configuration.md | 15 ++- .../introduction/installation.md | 12 +- .../version-latest/language-basics/imports.md | 17 ++- .../libraries/events/reference/decorators.md | 112 ++++++++++++++++++ .../libraries/events/reference/index.mdx | 40 +++++++ .../events/reference/js-api/_category_.json | 1 + .../reference/js-api/functions/$onValidate.md | 18 +++ .../js-api/functions/getContentType.md | 19 +++ .../reference/js-api/functions/isEventData.md | 19 +++ .../reference/js-api/functions/isEvents.md | 19 +++ .../events/reference/js-api/index.md | 16 +++ .../reference/js-api/variables/$decorators.md | 17 +++ .../events/reference/js-api/variables/$lib.md | 18 +++ .../libraries/http/reference/js-api/index.md | 4 +- .../libraries/sse/reference/data-types.md | 71 +++++++++++ .../libraries/sse/reference/decorators.md | 26 ++++ .../libraries/sse/reference/index.mdx | 42 +++++++ .../sse/reference/js-api/_category_.json | 1 + .../reference/js-api/functions/$onValidate.md | 18 +++ .../js-api/functions/isTerminalEvent.md | 19 +++ .../libraries/sse/reference/js-api/index.md | 14 +++ .../reference/js-api/variables/$decorators.md | 15 +++ .../sse/reference/js-api/variables/$lib.md | 15 +++ .../libraries/stream/reference/data-types.md | 31 +++++ .../libraries/stream/reference/decorators.md | 42 +++++++ .../libraries/stream/reference/index.mdx | 42 +++++++ .../libraries/streams/reference/data-types.md | 31 +++++ .../libraries/streams/reference/decorators.md | 42 +++++++ .../libraries/streams/reference/index.mdx | 42 +++++++ .../streams/reference/js-api/_category_.json | 1 + .../reference/js-api/functions/getStreamOf.md | 19 +++ .../reference/js-api/functions/isStream.md | 19 +++ .../streams/reference/js-api/index.md | 14 +++ .../reference/js-api/variables/$decorators.md | 15 +++ .../reference/js-api/variables/$lib.md | 8 ++ .../release-notes/release-2024-10-09.md | 90 ++++++++++++++ .../diags/triple-quote-indent.md | 25 ++++ .../standard-library/examples.md | 12 ++ .../js-api/classes/DuplicateTracker.md | 4 +- .../reference/js-api/enumerations/Token.md | 2 +- .../js-api/functions/checkFormatCadl.md | 2 + .../js-api/functions/createCadlLibrary.md | 19 +++ .../reference/js-api/functions/getEncode.md | 6 +- .../reference/js-api/functions/getFormat.md | 6 +- .../js-api/functions/getFriendlyName.md | 6 +- .../reference/js-api/functions/getKeyName.md | 4 +- .../js-api/functions/getKnownValues.md | 6 +- .../functions/getOverloadedOperation.md | 16 +-- .../js-api/functions/getOverloads.md | 16 +-- .../functions/getParameterVisibility.md | 12 +- .../js-api/functions/getPatternData.md | 17 +-- .../functions/getReturnTypeVisibility.md | 12 +- .../reference/js-api/functions/getService.md | 16 +-- .../reference/js-api/functions/getSummary.md | 4 +- .../js-api/functions/getVisibility.md | 6 +- .../js-api/functions/isCadlValueTypeOf.md | 2 + .../reference/js-api/functions/isSecret.md | 6 +- .../js-api/functions/resolveModule.md | 8 +- .../reference/js-api/index.md | 42 ++++--- .../js-api/interfaces/DecoratorArgument.md | 2 +- .../js-api/interfaces/DiagnosticDefinition.md | 25 +++- .../js-api/interfaces/IntrinsicType.md | 2 +- .../js-api/interfaces/LinterDefinition.md | 2 +- .../interfaces/LinterResolvedDefinition.md | 2 +- .../js-api/interfaces/NodePackage.md | 25 ---- .../js-api/interfaces/PackageFlags.md | 2 +- .../js-api/interfaces/PackageJson.md | 26 ++++ .../js-api/interfaces/ProjectedProgram.md | 2 +- .../ProjectionArithmeticExpressionNode.md | 2 +- .../js-api/interfaces/ResolveModuleOptions.md | 12 +- .../js-api/interfaces/ResolvedModule.md | 2 +- .../js-api/interfaces/SourceModel.md | 2 +- .../DiagnosticReportWithoutTarget.md | 4 +- ...LinterRuleDiagnosticReportWithoutTarget.md | 4 +- .../type-aliases/SemanticNodeListener.md | 2 +- .../version-latest-sidebars.json | 52 ++++++++ packages/xml/CHANGELOG.md | 7 ++ packages/xml/package.json | 2 +- 173 files changed, 1499 insertions(+), 589 deletions(-) delete mode 100644 .chronus/changes/1ds-mc1-ms0-2024-8-13-14-14-2.md delete mode 100644 .chronus/changes/InfoUnallowKeyChecker-2024-8-24-11-6-11.md delete mode 100644 .chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md delete mode 100644 .chronus/changes/add-streaming-2024-8-25-11-52-49.md delete mode 100644 .chronus/changes/add-streaming-2024-8-25-11-53-37.md delete mode 100644 .chronus/changes/add-streaming-2024-8-25-11-54-27.md delete mode 100644 .chronus/changes/add-streaming-2024-8-25-11-56-3.md delete mode 100644 .chronus/changes/add-streaming-2024-8-25-11-56-36.md delete mode 100644 .chronus/changes/almend-ScalarDefaultValue-2024-8-12-15-34-32.md delete mode 100644 .chronus/changes/config-invalid-name-2024-8-25-19-8-41.md delete mode 100644 .chronus/changes/decorator-arg-marshalling-new-default-2024-8-23-14-22-52.md delete mode 100644 .chronus/changes/decorator-arg-marshalling-new-default-2024-8-23-21-44-3.md delete mode 100644 .chronus/changes/diagnostic-url-2024-8-13-19-59-26.md delete mode 100644 .chronus/changes/feature-mutators-2024-7-28-15-59-14.md delete mode 100644 .chronus/changes/fix-e2e-not-checking-file-changed-2024-9-4-21-56-58.md delete mode 100644 .chronus/changes/fix-enum-in-union-example-2024-8-17-18-25-2.md delete mode 100644 .chronus/changes/fix-examples-const-2024-8-30-17-28-17.md delete mode 100644 .chronus/changes/fix-examples-encoded-name-2024-8-26-12-52-20.md delete mode 100644 .chronus/changes/fix-invalid-or-2024-8-18-21-5-24.md delete mode 100644 .chronus/changes/fix-not-handling-numeric-leading-0-mulitple-2024-8-24-10-20-50.md delete mode 100644 .chronus/changes/fix-playground-blank-screen-and-formatter-2024-8-26-12-35-15.md delete mode 100644 .chronus/changes/fix-project-source-models-2024-8-13-15-15-44.md delete mode 100644 .chronus/changes/fix-server-file-cache-2024-8-18-11-4-8.md delete mode 100644 .chronus/changes/fix-virtual-path-playground-2024-9-9-10-21-58.md delete mode 100644 .chronus/changes/fix-virtual-path-playground-2024-9-9-10-47-42.md delete mode 100644 .chronus/changes/fix-watch-config-2024-8-27-22-7-45.md delete mode 100644 .chronus/changes/format-trailling-commas-2024-8-16-18-56-35.md delete mode 100644 .chronus/changes/json-schema-examples-2024-8-13-16-5-45.md delete mode 100644 .chronus/changes/main-2024-8-4-15-6-54.md delete mode 100644 .chronus/changes/refactor-packagejson-type-2024-9-3-17-20-34.md delete mode 100644 .chronus/changes/refactor-state-accessor-2024-8-17-15-11-51.md delete mode 100644 .chronus/changes/refactor-state-accessor-2024-8-17-21-56-42.md delete mode 100644 .chronus/changes/resolve-module-exports-2024-9-4-18-32-9.md delete mode 100644 .chronus/changes/resolve-module-exports-2024-9-4-22-21-14.md delete mode 100644 .chronus/changes/support-variable-base-nested-config-2024-8-25-19-8-41.md delete mode 100644 .chronus/changes/termsOfServiceUrlCheck-2024-8-23-12-59-15.md delete mode 100644 .chronus/changes/upgrade-deps-sep-2024-2-2024-8-25-9-32-48.md delete mode 100644 .chronus/changes/upgrade-deps-sep-2024-2024-8-13-0-37-48.md delete mode 100644 .chronus/changes/upgrade-monaco-editor-2024-8-25-21-58-44.md delete mode 100644 .chronus/changes/use-shell-for-cmd-2024-8-13-11-39-59.md delete mode 100644 .chronus/changes/vscode-web-2024-8-23-20-15-22.md delete mode 100644 .chronus/changes/vscode-web-2024-8-23-21-44-3.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/events/reference/decorators.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/events/reference/index.mdx create mode 100644 packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/_category_.json create mode 100644 packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/$onValidate.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/getContentType.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/isEventData.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/isEvents.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/index.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/variables/$decorators.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/variables/$lib.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/sse/reference/data-types.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/sse/reference/decorators.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/sse/reference/index.mdx create mode 100644 packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/_category_.json create mode 100644 packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/functions/$onValidate.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/functions/isTerminalEvent.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/index.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/variables/$decorators.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/variables/$lib.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/stream/reference/data-types.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/stream/reference/decorators.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/stream/reference/index.mdx create mode 100644 packages/website/versioned_docs/version-latest/libraries/streams/reference/data-types.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/streams/reference/decorators.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/streams/reference/index.mdx create mode 100644 packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/_category_.json create mode 100644 packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/functions/getStreamOf.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/functions/isStream.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/index.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/variables/$decorators.md create mode 100644 packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/variables/$lib.md create mode 100644 packages/website/versioned_docs/version-latest/release-notes/release-2024-10-09.md create mode 100644 packages/website/versioned_docs/version-latest/standard-library/diags/triple-quote-indent.md delete mode 100644 packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/NodePackage.md create mode 100644 packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/PackageJson.md diff --git a/.chronus/changes/1ds-mc1-ms0-2024-8-13-14-14-2.md b/.chronus/changes/1ds-mc1-ms0-2024-8-13-14-14-2.md deleted file mode 100644 index b26c8dd246..0000000000 --- a/.chronus/changes/1ds-mc1-ms0-2024-8-13-14-14-2.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/html-program-viewer" - - "@typespec/playground" ---- - diff --git a/.chronus/changes/InfoUnallowKeyChecker-2024-8-24-11-6-11.md b/.chronus/changes/InfoUnallowKeyChecker-2024-8-24-11-6-11.md deleted file mode 100644 index caa79913d8..0000000000 --- a/.chronus/changes/InfoUnallowKeyChecker-2024-8-24-11-6-11.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/openapi" ---- - -`@info` decorator validate no extra properties not starting with `x-` are provided. diff --git a/.chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md b/.chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md deleted file mode 100644 index 9d91beab1f..0000000000 --- a/.chronus/changes/SemanticWalkerExitFixes-2024-9-9-10-27-23.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/compiler" ---- - -[API] Add missing exit callback diff --git a/.chronus/changes/add-streaming-2024-8-25-11-52-49.md b/.chronus/changes/add-streaming-2024-8-25-11-52-49.md deleted file mode 100644 index f3ea9a0511..0000000000 --- a/.chronus/changes/add-streaming-2024-8-25-11-52-49.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: feature -packages: - - "@typespec/events" ---- - -Adds a new core package for describing events. \ No newline at end of file diff --git a/.chronus/changes/add-streaming-2024-8-25-11-53-37.md b/.chronus/changes/add-streaming-2024-8-25-11-53-37.md deleted file mode 100644 index 9eff9f7a59..0000000000 --- a/.chronus/changes/add-streaming-2024-8-25-11-53-37.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: feature -packages: - - "@typespec/streams" ---- - -Adds a new core package for describing streams and the type of data they contain. diff --git a/.chronus/changes/add-streaming-2024-8-25-11-54-27.md b/.chronus/changes/add-streaming-2024-8-25-11-54-27.md deleted file mode 100644 index 51a7a423b4..0000000000 --- a/.chronus/changes/add-streaming-2024-8-25-11-54-27.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: feature -packages: - - "@typespec/sse" ---- - -Adds a new core package to describe server-sent events. \ No newline at end of file diff --git a/.chronus/changes/add-streaming-2024-8-25-11-56-3.md b/.chronus/changes/add-streaming-2024-8-25-11-56-3.md deleted file mode 100644 index 00b64884ff..0000000000 --- a/.chronus/changes/add-streaming-2024-8-25-11-56-3.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: feature -packages: - - "@typespec/http" ---- - -Adds HttpStream and JsonlStream models to to support streaming use-cases. \ No newline at end of file diff --git a/.chronus/changes/add-streaming-2024-8-25-11-56-36.md b/.chronus/changes/add-streaming-2024-8-25-11-56-36.md deleted file mode 100644 index 6d4e774ab0..0000000000 --- a/.chronus/changes/add-streaming-2024-8-25-11-56-36.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/compiler" ---- - -Fixes issue with the semantic walker where `exitTuple` was not being emitted. \ No newline at end of file diff --git a/.chronus/changes/almend-ScalarDefaultValue-2024-8-12-15-34-32.md b/.chronus/changes/almend-ScalarDefaultValue-2024-8-12-15-34-32.md deleted file mode 100644 index 234ab1f96b..0000000000 --- a/.chronus/changes/almend-ScalarDefaultValue-2024-8-12-15-34-32.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: feature -packages: - - "@typespec/openapi3" ---- - -Added support to use Scalar and Object as default types \ No newline at end of file diff --git a/.chronus/changes/config-invalid-name-2024-8-25-19-8-41.md b/.chronus/changes/config-invalid-name-2024-8-25-19-8-41.md deleted file mode 100644 index d63030015a..0000000000 --- a/.chronus/changes/config-invalid-name-2024-8-25-19-8-41.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: breaking -packages: - - "@typespec/compiler" ---- - -Config parameters and emitters options cannot contains `.`. This conflict with newly added support for nested options. diff --git a/.chronus/changes/decorator-arg-marshalling-new-default-2024-8-23-14-22-52.md b/.chronus/changes/decorator-arg-marshalling-new-default-2024-8-23-14-22-52.md deleted file mode 100644 index 92a38e36cb..0000000000 --- a/.chronus/changes/decorator-arg-marshalling-new-default-2024-8-23-14-22-52.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -changeKind: breaking -packages: - - "@typespec/compiler" ---- - -API: Update default of `decoratorArgMarshalling` from `legacy` to `new` - -To revert to the old behavior export the following. **Highly discouraged, this will be removed in a few versions.** - -```ts -export const $flags = definePackageFlags({ - decoratorArgMarshalling: "legacy", -}); -``` diff --git a/.chronus/changes/decorator-arg-marshalling-new-default-2024-8-23-21-44-3.md b/.chronus/changes/decorator-arg-marshalling-new-default-2024-8-23-21-44-3.md deleted file mode 100644 index 4b94b02c3f..0000000000 --- a/.chronus/changes/decorator-arg-marshalling-new-default-2024-8-23-21-44-3.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: internal -packages: - - "@typespec/json-schema" ---- - -Update decorator arg marshalling to new default diff --git a/.chronus/changes/diagnostic-url-2024-8-13-19-59-26.md b/.chronus/changes/diagnostic-url-2024-8-13-19-59-26.md deleted file mode 100644 index 856b5f4b35..0000000000 --- a/.chronus/changes/diagnostic-url-2024-8-13-19-59-26.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: feature -packages: - - "@typespec/compiler" ---- - -Library diagnostic can now define a `description` and `url` that links to a more detailed doc for this diagnostic diff --git a/.chronus/changes/feature-mutators-2024-7-28-15-59-14.md b/.chronus/changes/feature-mutators-2024-7-28-15-59-14.md deleted file mode 100644 index 16165268c0..0000000000 --- a/.chronus/changes/feature-mutators-2024-7-28-15-59-14.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: feature -packages: - - "@typespec/compiler" ---- - -Adding experimental (unstable) API fro Type Mutators \ No newline at end of file diff --git a/.chronus/changes/fix-e2e-not-checking-file-changed-2024-9-4-21-56-58.md b/.chronus/changes/fix-e2e-not-checking-file-changed-2024-9-4-21-56-58.md deleted file mode 100644 index b5c17c7e23..0000000000 --- a/.chronus/changes/fix-e2e-not-checking-file-changed-2024-9-4-21-56-58.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: internal -packages: - - "@typespec/compiler" ---- - -Check that e2e snapshot files are up to date diff --git a/.chronus/changes/fix-enum-in-union-example-2024-8-17-18-25-2.md b/.chronus/changes/fix-enum-in-union-example-2024-8-17-18-25-2.md deleted file mode 100644 index d25024443d..0000000000 --- a/.chronus/changes/fix-enum-in-union-example-2024-8-17-18-25-2.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: fix -packages: - - "@typespec/compiler" ---- - -Fix examples with enums inside of unions diff --git a/.chronus/changes/fix-examples-const-2024-8-30-17-28-17.md b/.chronus/changes/fix-examples-const-2024-8-30-17-28-17.md deleted file mode 100644 index 205f0a2871..0000000000 --- a/.chronus/changes/fix-examples-const-2024-8-30-17-28-17.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: fix -packages: - - "@typespec/compiler" ---- - -Fix: Passing `const` of model type to `@example` diff --git a/.chronus/changes/fix-examples-encoded-name-2024-8-26-12-52-20.md b/.chronus/changes/fix-examples-encoded-name-2024-8-26-12-52-20.md deleted file mode 100644 index fb1dd64ee3..0000000000 --- a/.chronus/changes/fix-examples-encoded-name-2024-8-26-12-52-20.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/compiler" ---- - -Json serialization of example respect `@encodedName` \ No newline at end of file diff --git a/.chronus/changes/fix-invalid-or-2024-8-18-21-5-24.md b/.chronus/changes/fix-invalid-or-2024-8-18-21-5-24.md deleted file mode 100644 index 282ca17dc9..0000000000 --- a/.chronus/changes/fix-invalid-or-2024-8-18-21-5-24.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: internal -packages: - - "@typespec/compiler" - - "@typespec/rest" ---- - -Fix regressions during refactor of state accessor diff --git a/.chronus/changes/fix-not-handling-numeric-leading-0-mulitple-2024-8-24-10-20-50.md b/.chronus/changes/fix-not-handling-numeric-leading-0-mulitple-2024-8-24-10-20-50.md deleted file mode 100644 index 160f43ab78..0000000000 --- a/.chronus/changes/fix-not-handling-numeric-leading-0-mulitple-2024-8-24-10-20-50.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/compiler" ---- - -Fix issue with decimal numeric and leading `0.0` with multiple digit diff --git a/.chronus/changes/fix-playground-blank-screen-and-formatter-2024-8-26-12-35-15.md b/.chronus/changes/fix-playground-blank-screen-and-formatter-2024-8-26-12-35-15.md deleted file mode 100644 index f1073d0f71..0000000000 --- a/.chronus/changes/fix-playground-blank-screen-and-formatter-2024-8-26-12-35-15.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/playground" ---- - diff --git a/.chronus/changes/fix-project-source-models-2024-8-13-15-15-44.md b/.chronus/changes/fix-project-source-models-2024-8-13-15-15-44.md deleted file mode 100644 index 9687ec4a92..0000000000 --- a/.chronus/changes/fix-project-source-models-2024-8-13-15-15-44.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/compiler" ---- - -[API] model `sourceModels` property are now projected correctly diff --git a/.chronus/changes/fix-server-file-cache-2024-8-18-11-4-8.md b/.chronus/changes/fix-server-file-cache-2024-8-18-11-4-8.md deleted file mode 100644 index d7ef43c29a..0000000000 --- a/.chronus/changes/fix-server-file-cache-2024-8-18-11-4-8.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/compiler" ---- - -Changing tspconfig.yaml won't take effect in LSP server because of the cache \ No newline at end of file diff --git a/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-21-58.md b/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-21-58.md deleted file mode 100644 index f1073d0f71..0000000000 --- a/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-21-58.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/playground" ---- - diff --git a/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-47-42.md b/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-47-42.md deleted file mode 100644 index f441bba5f0..0000000000 --- a/.chronus/changes/fix-virtual-path-playground-2024-9-9-10-47-42.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/compiler" ---- - diff --git a/.chronus/changes/fix-watch-config-2024-8-27-22-7-45.md b/.chronus/changes/fix-watch-config-2024-8-27-22-7-45.md deleted file mode 100644 index bd02cd3689..0000000000 --- a/.chronus/changes/fix-watch-config-2024-8-27-22-7-45.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: fix -packages: - - "@typespec/compiler" ---- - - `tsp compile --watch` reread from `tspconfig.yaml` file diff --git a/.chronus/changes/format-trailling-commas-2024-8-16-18-56-35.md b/.chronus/changes/format-trailling-commas-2024-8-16-18-56-35.md deleted file mode 100644 index 9c31d7c488..0000000000 --- a/.chronus/changes/format-trailling-commas-2024-8-16-18-56-35.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: internal -packages: - - "@typespec/bundler" - - "@typespec/compiler" - - "@typespec/eslint-plugin" - - "@typespec/html-program-viewer" - - "@typespec/http-server-csharp" - - "@typespec/http-server-javascript" - - "@typespec/http" - - "@typespec/internal-build-utils" - - "@typespec/json-schema" - - "@typespec/library-linter" - - "@typespec/openapi" - - "@typespec/openapi3" - - "@typespec/playground" - - "@typespec/protobuf" - - "@typespec/rest" - - typespec-vs - - typespec-vscode - - "@typespec/versioning" - - "@typespec/xml" ---- - -Update prettier config to format trailing commas to `all` (Default) diff --git a/.chronus/changes/json-schema-examples-2024-8-13-16-5-45.md b/.chronus/changes/json-schema-examples-2024-8-13-16-5-45.md deleted file mode 100644 index 5898f8280f..0000000000 --- a/.chronus/changes/json-schema-examples-2024-8-13-16-5-45.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: feature -packages: - - "@typespec/json-schema" ---- - -Example set with `@example` decorator will populate the schema `examples` property \ No newline at end of file diff --git a/.chronus/changes/main-2024-8-4-15-6-54.md b/.chronus/changes/main-2024-8-4-15-6-54.md deleted file mode 100644 index 81399d79cb..0000000000 --- a/.chronus/changes/main-2024-8-4-15-6-54.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: feature -packages: - - typespec-vscode ---- - -Support Compile Task and Watch Task in vscode. diff --git a/.chronus/changes/refactor-packagejson-type-2024-9-3-17-20-34.md b/.chronus/changes/refactor-packagejson-type-2024-9-3-17-20-34.md deleted file mode 100644 index c46bd3a4f8..0000000000 --- a/.chronus/changes/refactor-packagejson-type-2024-9-3-17-20-34.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: feature -packages: - - "@typespec/compiler" ---- - -Expose more accurate `PackageJson` type and deprecate `NodePackage` diff --git a/.chronus/changes/refactor-state-accessor-2024-8-17-15-11-51.md b/.chronus/changes/refactor-state-accessor-2024-8-17-15-11-51.md deleted file mode 100644 index 0c90c5c044..0000000000 --- a/.chronus/changes/refactor-state-accessor-2024-8-17-15-11-51.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/http-server-csharp" ---- - -Fix potential undefined \ No newline at end of file diff --git a/.chronus/changes/refactor-state-accessor-2024-8-17-21-56-42.md b/.chronus/changes/refactor-state-accessor-2024-8-17-21-56-42.md deleted file mode 100644 index ab42b7b40b..0000000000 --- a/.chronus/changes/refactor-state-accessor-2024-8-17-21-56-42.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: internal -packages: - - "@typespec/compiler" ---- - -Use reusable state accessor for compiler decorators diff --git a/.chronus/changes/resolve-module-exports-2024-9-4-18-32-9.md b/.chronus/changes/resolve-module-exports-2024-9-4-18-32-9.md deleted file mode 100644 index b4bf9236c0..0000000000 --- a/.chronus/changes/resolve-module-exports-2024-9-4-18-32-9.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: feature -packages: - - "@typespec/compiler" ---- - -Add support for node `exports` field. Specific typespec exports can be provided with the `typespec` field - -```json -"exports": { - ".": { - "typespec": "./lib/main.tsp", - }, - "./named": { - "typespec": "./lib/named.tsp", - } -} -``` diff --git a/.chronus/changes/resolve-module-exports-2024-9-4-22-21-14.md b/.chronus/changes/resolve-module-exports-2024-9-4-22-21-14.md deleted file mode 100644 index 6836d03702..0000000000 --- a/.chronus/changes/resolve-module-exports-2024-9-4-22-21-14.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: fix -packages: - - "@typespec/playground" ---- - -Do not treat path as relative internally diff --git a/.chronus/changes/support-variable-base-nested-config-2024-8-25-19-8-41.md b/.chronus/changes/support-variable-base-nested-config-2024-8-25-19-8-41.md deleted file mode 100644 index d66c74cc75..0000000000 --- a/.chronus/changes/support-variable-base-nested-config-2024-8-25-19-8-41.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: feature -packages: - - "@typespec/compiler" ---- - -Support nested emitter options \ No newline at end of file diff --git a/.chronus/changes/termsOfServiceUrlCheck-2024-8-23-12-59-15.md b/.chronus/changes/termsOfServiceUrlCheck-2024-8-23-12-59-15.md deleted file mode 100644 index 541f10403d..0000000000 --- a/.chronus/changes/termsOfServiceUrlCheck-2024-8-23-12-59-15.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/openapi" ---- - -`@info` decorator validate `termsOfService` is a valid url \ No newline at end of file diff --git a/.chronus/changes/upgrade-deps-sep-2024-2-2024-8-25-9-32-48.md b/.chronus/changes/upgrade-deps-sep-2024-2-2024-8-25-9-32-48.md deleted file mode 100644 index 6b99fa4a47..0000000000 --- a/.chronus/changes/upgrade-deps-sep-2024-2-2024-8-25-9-32-48.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -changeKind: internal -packages: - - "@typespec/bundler" - - "@typespec/compiler" - - "@typespec/eslint-plugin" - - "@typespec/html-program-viewer" - - "@typespec/http-server-csharp" - - "@typespec/http-server-javascript" - - "@typespec/http" - - "@typespec/internal-build-utils" - - "@typespec/json-schema" - - "@typespec/library-linter" - - "@typespec/openapi" - - "@typespec/openapi3" - - "@typespec/playground" - - "@typespec/prettier-plugin-typespec" - - "@typespec/protobuf" - - "@typespec/rest" - - tmlanguage-generator - - typespec-vscode - - "@typespec/versioning" - - "@typespec/xml" ---- - diff --git a/.chronus/changes/upgrade-deps-sep-2024-2024-8-13-0-37-48.md b/.chronus/changes/upgrade-deps-sep-2024-2024-8-13-0-37-48.md deleted file mode 100644 index 5dcf0fdf5b..0000000000 --- a/.chronus/changes/upgrade-deps-sep-2024-2024-8-13-0-37-48.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: dependencies -packages: - - "@typespec/bundler" - - "@typespec/compiler" - - "@typespec/eslint-plugin" - - "@typespec/html-program-viewer" - - "@typespec/http-server-csharp" - - "@typespec/http-server-javascript" - - "@typespec/http" - - "@typespec/internal-build-utils" - - "@typespec/json-schema" - - "@typespec/library-linter" - - "@typespec/openapi" - - "@typespec/openapi3" - - "@typespec/playground" - - "@typespec/prettier-plugin-typespec" - - "@typespec/protobuf" - - "@typespec/rest" - - tmlanguage-generator - - typespec-vscode - - "@typespec/versioning" - - "@typespec/xml" ---- - -Bump dependencies diff --git a/.chronus/changes/upgrade-monaco-editor-2024-8-25-21-58-44.md b/.chronus/changes/upgrade-monaco-editor-2024-8-25-21-58-44.md deleted file mode 100644 index 20911ef824..0000000000 --- a/.chronus/changes/upgrade-monaco-editor-2024-8-25-21-58-44.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: feature -packages: - - "@typespec/playground" ---- - -Upgrade to latest monaco-editor diff --git a/.chronus/changes/use-shell-for-cmd-2024-8-13-11-39-59.md b/.chronus/changes/use-shell-for-cmd-2024-8-13-11-39-59.md deleted file mode 100644 index b3e569d0fa..0000000000 --- a/.chronus/changes/use-shell-for-cmd-2024-8-13-11-39-59.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - typespec-vscode ---- - -Use "shell" when spawning execution of .cmd file(i.e. tsp-server.cmd) in windows diff --git a/.chronus/changes/vscode-web-2024-8-23-20-15-22.md b/.chronus/changes/vscode-web-2024-8-23-20-15-22.md deleted file mode 100644 index d2e59acf6f..0000000000 --- a/.chronus/changes/vscode-web-2024-8-23-20-15-22.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: feature -packages: - - typespec-vscode ---- - -Make extension web compatible with minimal functionality diff --git a/.chronus/changes/vscode-web-2024-8-23-21-44-3.md b/.chronus/changes/vscode-web-2024-8-23-21-44-3.md deleted file mode 100644 index c8a42008c9..0000000000 --- a/.chronus/changes/vscode-web-2024-8-23-21-44-3.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking -changeKind: fix -packages: - - "@typespec/internal-build-utils" ---- - -Ignore test from third party notice generation diff --git a/packages/bundler/CHANGELOG.md b/packages/bundler/CHANGELOG.md index 3562788cd5..cc6ab132a8 100644 --- a/packages/bundler/CHANGELOG.md +++ b/packages/bundler/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log - @typespec/bundler +## 0.1.8 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.1.7 ### Bug Fixes diff --git a/packages/bundler/package.json b/packages/bundler/package.json index 79fde26335..4fd43d5f27 100644 --- a/packages/bundler/package.json +++ b/packages/bundler/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/bundler", - "version": "0.1.7", + "version": "0.1.8", "author": "Microsoft Corporation", "description": "Package to bundle a TypeSpec library.", "homepage": "https://typespec.io", diff --git a/packages/compiler/CHANGELOG.md b/packages/compiler/CHANGELOG.md index 00bc024a8b..68af7a7f00 100644 --- a/packages/compiler/CHANGELOG.md +++ b/packages/compiler/CHANGELOG.md @@ -1,5 +1,56 @@ # Change Log - @typespec/compiler +## 0.61.0 + +### Bug Fixes + +- [#4626](https://github.com/microsoft/typespec/pull/4626) [API] Add missing exit callback +- [#4513](https://github.com/microsoft/typespec/pull/4513) Fixes issue with the semantic walker where `exitTuple` was not being emitted. +- [#4462](https://github.com/microsoft/typespec/pull/4462) Fix examples with enums inside of unions +- [#4574](https://github.com/microsoft/typespec/pull/4574) Fix: Passing `const` of model type to `@example` +- [#4551](https://github.com/microsoft/typespec/pull/4551) Json serialization of example respect `@encodedName` +- [#4514](https://github.com/microsoft/typespec/pull/4514) Fix issue with decimal numeric and leading `0.0` with multiple digit +- [#4445](https://github.com/microsoft/typespec/pull/4445) [API] model `sourceModels` property are now projected correctly +- [#4467](https://github.com/microsoft/typespec/pull/4467) Changing tspconfig.yaml won't take effect in LSP server because of the cache +- [#4563](https://github.com/microsoft/typespec/pull/4563) `tsp compile --watch` reread from `tspconfig.yaml` file + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + +### Features + +- [#4442](https://github.com/microsoft/typespec/pull/4442) Library diagnostic can now define a `description` and `url` that links to a more detailed doc for this diagnostic +- [#4290](https://github.com/microsoft/typespec/pull/4290) Adding experimental (unstable) API fro Type Mutators +- [#4595](https://github.com/microsoft/typespec/pull/4595) Expose more accurate `PackageJson` type and deprecate `NodePackage` +- [#4606](https://github.com/microsoft/typespec/pull/4606) Add support for node `exports` field. Specific typespec exports can be provided with the `typespec` field + +```json +"exports": { + ".": { + "typespec": "./lib/main.tsp", + }, + "./named": { + "typespec": "./lib/named.tsp", + } +} +``` +- [#4539](https://github.com/microsoft/typespec/pull/4539) Support nested emitter options + +### Breaking Changes + +- [#4539](https://github.com/microsoft/typespec/pull/4539) Config parameters and emitters options cannot contains `.`. This conflict with newly added support for nested options. +- [#4500](https://github.com/microsoft/typespec/pull/4500) API: Update default of `decoratorArgMarshalling` from `legacy` to `new` + +To revert to the old behavior export the following. **Highly discouraged, this will be removed in a few versions.** + +```ts +export const $flags = definePackageFlags({ + decoratorArgMarshalling: "legacy", +}); +``` + + ## 0.60.1 ### Bug Fixes diff --git a/packages/compiler/package.json b/packages/compiler/package.json index 34f5d7bac7..c674698152 100644 --- a/packages/compiler/package.json +++ b/packages/compiler/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/compiler", - "version": "0.60.1", + "version": "0.61.0", "description": "TypeSpec Compiler Preview", "author": "Microsoft Corporation", "license": "MIT", diff --git a/packages/compiler/templates/scaffolding.json b/packages/compiler/templates/scaffolding.json index 74397a24bf..780c5765c1 100644 --- a/packages/compiler/templates/scaffolding.json +++ b/packages/compiler/templates/scaffolding.json @@ -3,12 +3,12 @@ "title": "Empty project", "description": "Create an empty project.", "libraries": [], - "compilerVersion": "0.60.1" + "compilerVersion": "0.61.0" }, "rest": { "title": "Generic REST API", "description": "Create a project representing a generic REST API", - "compilerVersion": "0.60.1", + "compilerVersion": "0.61.0", "libraries": [ "@typespec/http", "@typespec/rest", @@ -23,7 +23,7 @@ "library-ts": { "title": "TypeSpec Library (With TypeScript)", "description": "Create a new package to add decorators or linters to typespec.", - "compilerVersion": "0.60.1", + "compilerVersion": "0.61.0", "libraries": [], "files": [ { @@ -99,7 +99,7 @@ "emitter-ts": { "title": "TypeSpec Emitter (With TypeScript)", "description": "Create a new package that will be emitting typespec", - "compilerVersion": "0.60.1", + "compilerVersion": "0.61.0", "libraries": [], "files": [ { diff --git a/packages/eslint-plugin-typespec/CHANGELOG.md b/packages/eslint-plugin-typespec/CHANGELOG.md index 86aaa11783..e06be07b6a 100644 --- a/packages/eslint-plugin-typespec/CHANGELOG.md +++ b/packages/eslint-plugin-typespec/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log - @typespec/eslint-plugin +## 0.61.0 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.60.0 No changes, version bump only. diff --git a/packages/eslint-plugin-typespec/package.json b/packages/eslint-plugin-typespec/package.json index edf6fc8e39..5f228e618c 100644 --- a/packages/eslint-plugin-typespec/package.json +++ b/packages/eslint-plugin-typespec/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/eslint-plugin", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "Eslint plugin providing set of rules to be used in the JS/TS code of TypeSpec libraries", "homepage": "https://typespec.io", diff --git a/packages/events/CHANGELOG.md b/packages/events/CHANGELOG.md index 84aaa27d33..994030b8f4 100644 --- a/packages/events/CHANGELOG.md +++ b/packages/events/CHANGELOG.md @@ -1 +1,8 @@ # Changelog - @typespec/events + +## 0.61.0 + +### Features + +- [#4513](https://github.com/microsoft/typespec/pull/4513) Adds a new core package for describing events. + diff --git a/packages/events/package.json b/packages/events/package.json index f8e3a2510c..ecc32d6d1b 100644 --- a/packages/events/package.json +++ b/packages/events/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/events", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec library providing events bindings", "homepage": "https://typespec.io", diff --git a/packages/html-program-viewer/CHANGELOG.md b/packages/html-program-viewer/CHANGELOG.md index bd64a97979..de01816d4b 100644 --- a/packages/html-program-viewer/CHANGELOG.md +++ b/packages/html-program-viewer/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log - @typespec/html-program-viewer +## 0.61.0 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.60.0 ### Bug Fixes diff --git a/packages/html-program-viewer/package.json b/packages/html-program-viewer/package.json index daf1657180..38598c9404 100644 --- a/packages/html-program-viewer/package.json +++ b/packages/html-program-viewer/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/html-program-viewer", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec library for emitting an html view of the program.", "homepage": "https://typespec.io", diff --git a/packages/http-server-csharp/CHANGELOG.md b/packages/http-server-csharp/CHANGELOG.md index c2f9e93cf3..a570eafe60 100644 --- a/packages/http-server-csharp/CHANGELOG.md +++ b/packages/http-server-csharp/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log - @typespec/http-server-csharp +## 0.58.0-alpha.4 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.58.0-alpha.3 No changes, version bump only. diff --git a/packages/http-server-csharp/package.json b/packages/http-server-csharp/package.json index d0ddae7e0b..6a21ce74e8 100644 --- a/packages/http-server-csharp/package.json +++ b/packages/http-server-csharp/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/http-server-csharp", - "version": "0.58.0-alpha.3", + "version": "0.58.0-alpha.4", "author": "Microsoft Corporation", "description": "TypeSpec service code generator for c-sharp", "homepage": "https://typespec.io", diff --git a/packages/http-server-javascript/CHANGELOG.md b/packages/http-server-javascript/CHANGELOG.md index b502fb05cf..b016b6d0ea 100644 --- a/packages/http-server-javascript/CHANGELOG.md +++ b/packages/http-server-javascript/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog - @typespec/http-server-javascript +## 0.58.0-alpha.4 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.58.0-alpha.3 No changes, version bump only. diff --git a/packages/http-server-javascript/package.json b/packages/http-server-javascript/package.json index e18d2c6dad..81494c6ee5 100644 --- a/packages/http-server-javascript/package.json +++ b/packages/http-server-javascript/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/http-server-javascript", - "version": "0.58.0-alpha.3", + "version": "0.58.0-alpha.4", "author": "Microsoft Corporation", "description": "TypeSpec HTTP server code generator for JavaScript", "homepage": "https://github.com/microsoft/typespec", diff --git a/packages/http/CHANGELOG.md b/packages/http/CHANGELOG.md index 6e09e7ed10..306a71d0b3 100644 --- a/packages/http/CHANGELOG.md +++ b/packages/http/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log - @typespec/http +## 0.61.0 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + +### Features + +- [#4513](https://github.com/microsoft/typespec/pull/4513) Adds HttpStream and JsonlStream models to to support streaming use-cases. + + ## 0.60.0 ### Bug Fixes diff --git a/packages/http/package.json b/packages/http/package.json index 657f7731f9..871fa09eb1 100644 --- a/packages/http/package.json +++ b/packages/http/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/http", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec HTTP protocol binding", "homepage": "https://github.com/microsoft/typespec", diff --git a/packages/internal-build-utils/CHANGELOG.md b/packages/internal-build-utils/CHANGELOG.md index 8c647e2286..9c8ef1ba6b 100644 --- a/packages/internal-build-utils/CHANGELOG.md +++ b/packages/internal-build-utils/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log - @typespec/internal-build-utils +## 0.61.0 + +### Bug Fixes + +- [#4498](https://github.com/microsoft/typespec/pull/4498) Ignore test from third party notice generation + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.60.0 No changes, version bump only. diff --git a/packages/internal-build-utils/package.json b/packages/internal-build-utils/package.json index 83212dedb8..d8ce92004e 100644 --- a/packages/internal-build-utils/package.json +++ b/packages/internal-build-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/internal-build-utils", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "Internal library to TypeSpec providing helpers to build.", "homepage": "https://typespec.io", diff --git a/packages/json-schema/CHANGELOG.md b/packages/json-schema/CHANGELOG.md index aa44aaa29d..edd2f6010a 100644 --- a/packages/json-schema/CHANGELOG.md +++ b/packages/json-schema/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log - @typespec/json-schema +## 0.61.0 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + +### Features + +- [#4447](https://github.com/microsoft/typespec/pull/4447) Example set with `@example` decorator will populate the schema `examples` property + + ## 0.60.0 ### Bug Fixes diff --git a/packages/json-schema/package.json b/packages/json-schema/package.json index 225f848af7..4e164ca233 100644 --- a/packages/json-schema/package.json +++ b/packages/json-schema/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/json-schema", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec library for emitting TypeSpec to JSON Schema and converting JSON Schema to TypeSpec", "homepage": "https://github.com/microsoft/typespec", diff --git a/packages/library-linter/CHANGELOG.md b/packages/library-linter/CHANGELOG.md index 9a36b88c38..a50ec3bd62 100644 --- a/packages/library-linter/CHANGELOG.md +++ b/packages/library-linter/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log - @typespec/library-linter +## 0.61.0 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.60.0 No changes, version bump only. diff --git a/packages/library-linter/package.json b/packages/library-linter/package.json index f40896497b..f45bce98f2 100644 --- a/packages/library-linter/package.json +++ b/packages/library-linter/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/library-linter", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec library for linting another library.", "homepage": "https://typespec.io", diff --git a/packages/openapi/CHANGELOG.md b/packages/openapi/CHANGELOG.md index 6a276e46a7..acde8e44f7 100644 --- a/packages/openapi/CHANGELOG.md +++ b/packages/openapi/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log - @typespec/openapi +## 0.61.0 + +### Bug Fixes + +- [#4505](https://github.com/microsoft/typespec/pull/4505) `@info` decorator validate no extra properties not starting with `x-` are provided. +- [#4483](https://github.com/microsoft/typespec/pull/4483) `@info` decorator validate `termsOfService` is a valid url + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.60.0 ### Features diff --git a/packages/openapi/package.json b/packages/openapi/package.json index a06d52df44..8799b2ee24 100644 --- a/packages/openapi/package.json +++ b/packages/openapi/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/openapi", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec library providing OpenAPI concepts", "homepage": "https://typespec.io", diff --git a/packages/openapi3/CHANGELOG.md b/packages/openapi3/CHANGELOG.md index 8e17476962..15517d8dea 100644 --- a/packages/openapi3/CHANGELOG.md +++ b/packages/openapi3/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log - @typespec/openapi3 +## 0.61.0 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + +### Features + +- [#4423](https://github.com/microsoft/typespec/pull/4423) Added support to use Scalar and Object as default types + + ## 0.60.0 ### Bug Fixes diff --git a/packages/openapi3/package.json b/packages/openapi3/package.json index 28bc259281..a289307e7c 100644 --- a/packages/openapi3/package.json +++ b/packages/openapi3/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/openapi3", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec library for emitting OpenAPI 3.0 from the TypeSpec REST protocol binding and converting OpenAPI3 to TypeSpec", "homepage": "https://typespec.io", diff --git a/packages/playground/CHANGELOG.md b/packages/playground/CHANGELOG.md index d3051356e7..edcbd988ab 100644 --- a/packages/playground/CHANGELOG.md +++ b/packages/playground/CHANGELOG.md @@ -1,5 +1,20 @@ # Change Log - @typespec/playground +## 0.5.0 + +### Bug Fixes + +- [#4606](https://github.com/microsoft/typespec/pull/4606) Do not treat path as relative internally + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + +### Features + +- [#4538](https://github.com/microsoft/typespec/pull/4538) Upgrade to latest monaco-editor + + ## 0.4.2 ### Bug Fixes diff --git a/packages/playground/package.json b/packages/playground/package.json index f8d64dd3e0..7bf5d3e3e5 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/playground", - "version": "0.4.2", + "version": "0.5.0", "author": "Microsoft Corporation", "description": "TypeSpec playground UI components.", "homepage": "https://typespec.io", diff --git a/packages/prettier-plugin-typespec/CHANGELOG.md b/packages/prettier-plugin-typespec/CHANGELOG.md index 97ba60e8c3..f2230b3d27 100644 --- a/packages/prettier-plugin-typespec/CHANGELOG.md +++ b/packages/prettier-plugin-typespec/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log - @typespec/prettier-plugin-typespec +## 0.61.0 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.60.0 No changes, version bump only. diff --git a/packages/prettier-plugin-typespec/package.json b/packages/prettier-plugin-typespec/package.json index f27f06ded6..52a08d92b8 100644 --- a/packages/prettier-plugin-typespec/package.json +++ b/packages/prettier-plugin-typespec/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/prettier-plugin-typespec", - "version": "0.60.0", + "version": "0.61.0", "description": "", "main": "dist/index.js", "scripts": { diff --git a/packages/protobuf/CHANGELOG.md b/packages/protobuf/CHANGELOG.md index af6a5194fe..a4e8f070b4 100644 --- a/packages/protobuf/CHANGELOG.md +++ b/packages/protobuf/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log - @typespec/protobuf +## 0.61.0 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.60.0 ### Features diff --git a/packages/protobuf/package.json b/packages/protobuf/package.json index 8422df5ffe..41357823cf 100644 --- a/packages/protobuf/package.json +++ b/packages/protobuf/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/protobuf", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec library and emitter for Protobuf (gRPC)", "homepage": "https://github.com/microsoft/typespec", diff --git a/packages/rest/CHANGELOG.md b/packages/rest/CHANGELOG.md index afa7e4de85..45281d1f19 100644 --- a/packages/rest/CHANGELOG.md +++ b/packages/rest/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log - @typespec/rest +## 0.61.0 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.60.0 ### Features diff --git a/packages/rest/package.json b/packages/rest/package.json index 560d9df340..aa1097adfc 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/rest", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec REST protocol binding", "homepage": "https://typespec.io", diff --git a/packages/sse/CHANGELOG.md b/packages/sse/CHANGELOG.md index b6a447457c..ebb9f4da1a 100644 --- a/packages/sse/CHANGELOG.md +++ b/packages/sse/CHANGELOG.md @@ -1 +1,8 @@ # Changelog - @typespec/sse + +## 0.61.0 + +### Features + +- [#4513](https://github.com/microsoft/typespec/pull/4513) Adds a new core package to describe server-sent events. + diff --git a/packages/sse/package.json b/packages/sse/package.json index 7c251fc22d..f2503bf78f 100644 --- a/packages/sse/package.json +++ b/packages/sse/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/sse", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec library providing server sent events bindings", "homepage": "https://typespec.io", diff --git a/packages/streams/CHANGELOG.md b/packages/streams/CHANGELOG.md index 87db52e4a7..7b91286dd8 100644 --- a/packages/streams/CHANGELOG.md +++ b/packages/streams/CHANGELOG.md @@ -1 +1,8 @@ # Changelog - @typespec/streams + +## 0.61.0 + +### Features + +- [#4513](https://github.com/microsoft/typespec/pull/4513) Adds a new core package for describing streams and the type of data they contain. + diff --git a/packages/streams/package.json b/packages/streams/package.json index bc902655d2..2a70ab78ee 100644 --- a/packages/streams/package.json +++ b/packages/streams/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/streams", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec library providing stream bindings", "homepage": "https://typespec.io", diff --git a/packages/tmlanguage-generator/CHANGELOG.md b/packages/tmlanguage-generator/CHANGELOG.md index 64dccf1980..aaeabf43af 100644 --- a/packages/tmlanguage-generator/CHANGELOG.md +++ b/packages/tmlanguage-generator/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log - tmlanguage-generator +## 0.5.9 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.5.8 ### Bump dependencies diff --git a/packages/tmlanguage-generator/package.json b/packages/tmlanguage-generator/package.json index 3d0513b2a0..ebb072f1c2 100644 --- a/packages/tmlanguage-generator/package.json +++ b/packages/tmlanguage-generator/package.json @@ -1,6 +1,6 @@ { "name": "tmlanguage-generator", - "version": "0.5.8", + "version": "0.5.9", "author": "Microsoft Corporation", "description": "Helper library to generate TextMate syntax highlighting tmLanguage files.", "homepage": "https://github.com/microsoft/typespec/tree/main/packages/tmlanguage-generator", diff --git a/packages/typespec-vs/CHANGELOG.md b/packages/typespec-vs/CHANGELOG.md index 14194e139a..e9d6318c8c 100644 --- a/packages/typespec-vs/CHANGELOG.md +++ b/packages/typespec-vs/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log - typespec-vs +## 0.61.0 + +No changes, version bump only. + ## 0.60.0 No changes, version bump only. diff --git a/packages/typespec-vs/package.json b/packages/typespec-vs/package.json index 90cb9a96cc..14768d4b96 100644 --- a/packages/typespec-vs/package.json +++ b/packages/typespec-vs/package.json @@ -1,7 +1,7 @@ { "name": "typespec-vs", "author": "Microsoft Corporation", - "version": "0.60.0", + "version": "0.61.0", "description": "TypeSpec Language Support for Visual Studio", "homepage": "https://typespec.io", "readme": "https://github.com/microsoft/typespec/blob/main/README.md", diff --git a/packages/typespec-vscode/CHANGELOG.md b/packages/typespec-vscode/CHANGELOG.md index 401cdfffba..54c7f2259c 100644 --- a/packages/typespec-vscode/CHANGELOG.md +++ b/packages/typespec-vscode/CHANGELOG.md @@ -1,5 +1,21 @@ # Change Log - typespec-vscode +## 0.61.0 + +### Bug Fixes + +- [#4430](https://github.com/microsoft/typespec/pull/4430) Use "shell" when spawning execution of .cmd file(i.e. tsp-server.cmd) in windows + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + +### Features + +- [#4330](https://github.com/microsoft/typespec/pull/4330) Support Compile Task and Watch Task in vscode. +- [#4498](https://github.com/microsoft/typespec/pull/4498) Make extension web compatible with minimal functionality + + ## 0.60.0 No changes, version bump only. diff --git a/packages/typespec-vscode/package.json b/packages/typespec-vscode/package.json index 7f50732b85..a8794e6988 100644 --- a/packages/typespec-vscode/package.json +++ b/packages/typespec-vscode/package.json @@ -1,6 +1,6 @@ { "name": "typespec-vscode", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec language support for VS Code", "homepage": "https://typespec.io", diff --git a/packages/versioning/CHANGELOG.md b/packages/versioning/CHANGELOG.md index f686350387..ad486fd09a 100644 --- a/packages/versioning/CHANGELOG.md +++ b/packages/versioning/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log - @typespec/versioning +## 0.61.0 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.60.1 ### Bug Fixes diff --git a/packages/versioning/package.json b/packages/versioning/package.json index 05e9af75aa..ba79b86ed4 100644 --- a/packages/versioning/package.json +++ b/packages/versioning/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/versioning", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec library for declaring and emitting versioned APIs", "homepage": "https://typespec.io", diff --git a/packages/website/playground-versions.json b/packages/website/playground-versions.json index fcab092f2c..4bf89b81a2 100644 --- a/packages/website/playground-versions.json +++ b/packages/website/playground-versions.json @@ -1,4 +1,5 @@ [ + "0.61.x", "0.60.x", "0.59.x", "0.58.x", diff --git a/packages/website/versioned_docs/version-latest/emitters/openapi3/reference/js-api/variables/$lib.md b/packages/website/versioned_docs/version-latest/emitters/openapi3/reference/js-api/variables/$lib.md index cbe951f393..3650b2262d 100644 --- a/packages/website/versioned_docs/version-latest/emitters/openapi3/reference/js-api/variables/$lib.md +++ b/packages/website/versioned_docs/version-latest/emitters/openapi3/reference/js-api/variables/$lib.md @@ -23,8 +23,6 @@ const $lib: TypeSpecLibrary; | `inconsistent-shared-route-request-visibility.default` | "All operations with \`@sharedRoutes\` must have the same \`@requestVisibility\`." | "All operations with \`@sharedRoutes\` must have the same \`@requestVisibility\`." | | `inline-cycle` | `object` | - | | `inline-cycle.default` | `CallableMessage`<[`"type"`]\> | - | -| `invalid-default` | `object` | - | -| `invalid-default.default` | `CallableMessage`<[`"type"`]\> | - | | `invalid-format` | `object` | - | | `invalid-format.default` | `CallableMessage`<[`"value"`, `"paramType"`]\> | - | | `invalid-model-property` | `object` | - | diff --git a/packages/website/versioned_docs/version-latest/emitters/protobuf/reference/js-api/index.md b/packages/website/versioned_docs/version-latest/emitters/protobuf/reference/js-api/index.md index b12f9c2132..39bf6d574f 100644 --- a/packages/website/versioned_docs/version-latest/emitters/protobuf/reference/js-api/index.md +++ b/packages/website/versioned_docs/version-latest/emitters/protobuf/reference/js-api/index.md @@ -14,8 +14,8 @@ title: "[P] JS API" ## Variables - [$lib](variables/$lib.md) -- [PROTO\_FULL\_IDENT](variables/PROTO_FULL_IDENT.md) - [namespace](variables/namespace.md) +- [PROTO\_FULL\_IDENT](variables/PROTO_FULL_IDENT.md) ## Functions diff --git a/packages/website/versioned_docs/version-latest/extending-typespec/basics.md b/packages/website/versioned_docs/version-latest/extending-typespec/basics.md index 05d3cb92a8..4deefa490b 100644 --- a/packages/website/versioned_docs/version-latest/extending-typespec/basics.md +++ b/packages/website/versioned_docs/version-latest/extending-typespec/basics.md @@ -75,7 +75,19 @@ Your package.json needs to refer to two main files: your Node module main file, ```jsonc "main": "dist/src/index.js", - "tspMain": "lib/main.tsp" + "exports": { + ".": { + "typespec": "./lib/main.tsp" + }, + // Additional named export are possible + "./experimental": { + "typespec": "./lib/experimental.tsp" + }, + // Wildcard export as well + "./lib/*": { + "typespec": "./lib/*.tsp" + } + } ``` ### d. Install and initialize TypeScript @@ -122,19 +134,7 @@ export const { reportDiagnostic, createDiagnostic } = $lib; Diagnostics are used for linters and decorators, which are covered in subsequent topics. -### f. Set package flags - -You can optionally set any package flags by exporting a `$flags` const that is initialized with the `definePackageFlags`. Like `$lib`, this value must be exported from your package. - -It is strongly recommended to set `valueMarshalling` to `"new"` as this will be the default behavior in future TypeSpec versions. - -```typescript -export const $flags = definePackageFlags({ - valueMarshalling: "new", -}); -``` - -### g. Create `index.ts` +### f. Create `index.ts` Open `./src/index.ts` and import your library definition: @@ -143,7 +143,7 @@ Open `./src/index.ts` and import your library definition: export { $lib } from "./lib.js"; ``` -### h. Build TypeScript +### g. Build TypeScript TypeSpec can only import JavaScript files, so any changes made to TypeScript sources need to be compiled before they are visible to TypeSpec. To do this, run `npx tsc -p .` in your library's root directory. If you want to re-run the TypeScript compiler whenever files are changed, you can run `npx tsc -p . --watch`. @@ -161,7 +161,7 @@ Alternatively, you can add these as scripts in your `package.json` to make them You can then run `npm run build` or `npm run watch` to build or watch your library. -### i. Add your main TypeSpec file +### h. Add your main TypeSpec file Open `./lib/main.tsp` and import your JS entrypoint. This ensures that when TypeSpec imports your library, the code to define the library is run. When we add decorators in later topics, this import will ensure those get exposed as well. diff --git a/packages/website/versioned_docs/version-latest/extending-typespec/emitter-metadata-handling.md b/packages/website/versioned_docs/version-latest/extending-typespec/emitter-metadata-handling.md index 6f91eef3da..70493280e7 100644 --- a/packages/website/versioned_docs/version-latest/extending-typespec/emitter-metadata-handling.md +++ b/packages/website/versioned_docs/version-latest/extending-typespec/emitter-metadata-handling.md @@ -17,7 +17,7 @@ If you're new to writing emitters, begin with the [emitter basics](./emitters-ba Next, examine the [REST metadata emitter sample](https://github.com/microsoft/typespec/tree/main/packages/samples/rest-metadata-emitter). This sample uses all of the APIs discussed below to create a simple textual representation. It intentionally avoids splitting types like the OpenAPI emitter to highlight that this is not mandatory. Instead, it includes contextual comments to indicate how data depends on context. -However, if you want your emitter to split types like OpenAPI, you can still use the same API. Cross-referencing with the official [OpenAPI emitter] where these APIs are called can also be helpful. +However, if you want your emitter to split types like OpenAPI, you can still use the same API. Cross-referencing with the official [OpenAPI emitter](../emitters/openapi3/openapi.md) where these APIs are called can also be helpful. ## Key API diff --git a/packages/website/versioned_docs/version-latest/extending-typespec/emitters-basics.md b/packages/website/versioned_docs/version-latest/extending-typespec/emitters-basics.md index 66d6f851eb..c7ea724509 100644 --- a/packages/website/versioned_docs/version-latest/extending-typespec/emitters-basics.md +++ b/packages/website/versioned_docs/version-latest/extending-typespec/emitters-basics.md @@ -5,7 +5,7 @@ title: Emitters # Creating emitters -TypeSpec emitters are libraries that utilize various TypeSpec compiler APIs to reflect on the TypeSpec compilation process and generate artifacts. The TypeSpec standard library includes an emitter for OpenAPI version 3.0. However, you might want to emit TypeSpec to a different output format. One of the main advantages of TypeSpec is its ease of use as a single source of truth for all data shapes, and the simplicity of creating an emitter contributes significantly to this. +TypeSpec emitters are libraries that utilize various TypeSpec compiler APIs to reflect on the TypeSpec compilation process and generate artifacts. The TypeSpec standard library includes emitters for OpenAPI version 3.0, JSON Schema, and Protocol Buffers (Protobuf). However, you might want to emit TypeSpec to a different output format. One of the main advantages of TypeSpec is its ease of use as a single source of truth for all data shapes, and the simplicity of creating an emitter contributes significantly to this. ## Emitter design @@ -128,6 +128,7 @@ Example: ### Configuration options convention - Name options `kebab-case`. So it can be inline with the rest of the cli +- Name options should not contain dots (`.`). Using a dot will conflict with using nested configuration values. - An option called `output-dir` can be created and should override the compiler `output-dir` #### Emitter options vs. decorators diff --git a/packages/website/versioned_docs/version-latest/handbook/configuration/configuration.md b/packages/website/versioned_docs/version-latest/handbook/configuration/configuration.md index 79948bbe35..d448452635 100644 --- a/packages/website/versioned_docs/version-latest/handbook/configuration/configuration.md +++ b/packages/website/versioned_docs/version-latest/handbook/configuration/configuration.md @@ -114,6 +114,8 @@ Here's what would be produced: #### Project Parameters A TypeSpec project file can define certain parameters that can subsequently be specified through the CLI. +Parameters can be organized in a nested structure, to access different levels of the structure, use dots (`.`) in the variable expression. +Therefore, parameter names should not contain `.` in their name. The `{cwd}` and `{project-root}` variables can be utilized in the default value of these parameters. @@ -130,7 +132,7 @@ parameters: output-dir: {base-dir}/output ``` -The parameter can then be specified via `--arg` in this format `--arg "="` +The parameter can then be specified via `--arg` in this format `--arg "="` and for nested structures `--arg ".="` ```bash tsp compile . --arg "base-dir=/path/to/base" @@ -170,6 +172,17 @@ options: ``` +Emitter options support a nested structure, enabling complex configurations. + +```yaml +options: + emitter-sub-folder: + sub-folder: bar +``` + +To set these values via the CLI, use dots to navigate deeper levels in the definition. `--option ".="` +Due to this capability, emitter option names should not contain a `.` in their name. + ## TypeSpec Configuration Options | Config | Cli | Description | diff --git a/packages/website/versioned_docs/version-latest/introduction/installation.md b/packages/website/versioned_docs/version-latest/introduction/installation.md index e219918c2f..969f8ef6d6 100644 --- a/packages/website/versioned_docs/version-latest/introduction/installation.md +++ b/packages/website/versioned_docs/version-latest/introduction/installation.md @@ -14,7 +14,17 @@ Install [Node.js 20 LTS](https://nodejs.org/en/download/) and ensure you can run npm --version ``` -We recommend using npm 7+. To update npm, run `npm install -g npm` +### Package manager + +TypeSpec uses node package linking to manage dependencies. Any package manager that produce a `node_modules` directory should work: + +- npm 7+. To update npm, run `npm install -g npm` +- pnpm +- yarn + +:::warning +Yarn will not automatically install implicit peerDependencies. TypeSpec libraries rely on this. Watch for warnings for any missing dependencies. +::: ## Install tsp diff --git a/packages/website/versioned_docs/version-latest/language-basics/imports.md b/packages/website/versioned_docs/version-latest/language-basics/imports.md index c8dfee102d..7ec9267e19 100644 --- a/packages/website/versioned_docs/version-latest/language-basics/imports.md +++ b/packages/website/versioned_docs/version-latest/language-basics/imports.md @@ -23,7 +23,7 @@ import "./decorators.js"; ## Importing a library -The import value can be the name of one of the package dependencies. In this case, TypeSpec will look for the `package.json` file and check the `tspMain` entry (defaulting to `main` if `tspMain` is absent) to determine the library entrypoint to load. +The import value can be the name of one of the package dependencies. ```typespec import "/rest"; @@ -32,12 +32,25 @@ import "/rest"; ```json // ./node_modules/@typespec/rest/package.json { - "tspMain": "./lib/main.tsp" + "exports": { + ".": { "typespec": "./lib/main.tsp" } + } } ``` This results in `./node_modules/@typespec/rest/lib/main.tsp` being imported. +### Package resolution algorithm + +When trying to import a package TypeSpec follows the following logic + +1. Parse the package name from the import specificier into `pkgName` and `subPath` (e.g. `@scope/lib/named` => pkgName: `@scope/lib` subpath: `named` ) +1. Look to see if `pkgName` is itself(Containing package) +1. Otherwise lookup for a parent folder with a `node_modules/${pkgName}` sub folder +1. Reading the `package.json` of the package + a. If `exports` is defined respect the [ESM logic](https://github.com/nodejs/node/blob/main/doc/api/esm.md) to resolve the `typespec` condition(TypeSpec will not respect the `default` condition) + b. If `exports` is not found or for back compat the `.` export is missing the `typespec` condition fallback to checking `tspMain` or `main` + ## Importing a directory If the import value is a directory, TypeSpec will check if that directory is a Node package and follow the npm package [lookup logic](#importing-a-library), or if the directory contains a `main.tsp` file. diff --git a/packages/website/versioned_docs/version-latest/libraries/events/reference/decorators.md b/packages/website/versioned_docs/version-latest/libraries/events/reference/decorators.md new file mode 100644 index 0000000000..69772a8bbd --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/events/reference/decorators.md @@ -0,0 +1,112 @@ +--- +title: "Decorators" +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +# Decorators + +## TypeSpec.Events + +### `@contentType` {#@TypeSpec.Events.contentType} + +Specifies the content type of the event envelope, event body, or event payload. +When applied to an event payload, that field must also have a corresponding `@data` +decorator. + +```typespec +@TypeSpec.Events.contentType(contentType: valueof string) +``` + +#### Target + +`UnionVariant | ModelProperty` + +#### Parameters + +| Name | Type | Description | +| ----------- | ---------------- | ----------- | +| contentType | `valueof string` | | + +#### Examples + +```typespec +@events +union MixedEvents { + @contentType("application/json") + message: { + id: string, + text: string, + }, +} +``` + +##### Specify the content type of the event payload. + +```typespec +@events +union MixedEvents { + { + done: true, + }, + { + done: false, + @data @contentType("text/plain") value: string, + }, +} +``` + +### `@data` {#@TypeSpec.Events.data} + +Identifies the payload of an event. +Only one field in an event can be marked as the payload. + +```typespec +@TypeSpec.Events.data +``` + +#### Target + +`ModelProperty` + +#### Parameters + +None + +#### Examples + +```typespec +@events +union MixedEvents { + { + metadata: Record, + @data payload: string, + }, +} +``` + +### `@events` {#@TypeSpec.Events.events} + +Specify that this union describes a set of events. + +```typespec +@TypeSpec.Events.events +``` + +#### Target + +`Union` + +#### Parameters + +None + +#### Examples + +```typespec +@events +union MixedEvents { + pingEvent: string, + doneEvent: "done", +} +``` diff --git a/packages/website/versioned_docs/version-latest/libraries/events/reference/index.mdx b/packages/website/versioned_docs/version-latest/libraries/events/reference/index.mdx new file mode 100644 index 0000000000..514d08760f --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/events/reference/index.mdx @@ -0,0 +1,40 @@ +--- +title: Overview +sidebar_position: 0 +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Overview + +TypeSpec library providing events bindings + +## Install + + + + +```bash +npm install @typespec/events +``` + + + + +```bash +npm install --save-peer @typespec/events +``` + + + + +## TypeSpec.Events + +### Decorators + +- [`@contentType`](./decorators.md#@TypeSpec.Events.contentType) +- [`@data`](./decorators.md#@TypeSpec.Events.data) +- [`@events`](./decorators.md#@TypeSpec.Events.events) diff --git a/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/_category_.json b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/_category_.json new file mode 100644 index 0000000000..bc91d15cee --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/_category_.json @@ -0,0 +1 @@ +{"label":"JS API","link":{"type":"doc","id":"index"}} \ No newline at end of file diff --git a/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/$onValidate.md b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/$onValidate.md new file mode 100644 index 0000000000..42cb14e224 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/$onValidate.md @@ -0,0 +1,18 @@ +--- +jsApi: true +title: "[F] $onValidate" + +--- +```ts +function $onValidate(program): void +``` + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `program` | `Program` | + +## Returns + +`void` diff --git a/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/getContentType.md b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/getContentType.md new file mode 100644 index 0000000000..e90588f975 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/getContentType.md @@ -0,0 +1,19 @@ +--- +jsApi: true +title: "[F] getContentType" + +--- +```ts +function getContentType(program, type): undefined | string +``` + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `program` | `Program` | +| `type` | `ModelProperty` \| `UnionVariant` | + +## Returns + +`undefined` \| `string` diff --git a/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/isEventData.md b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/isEventData.md new file mode 100644 index 0000000000..23347f446c --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/isEventData.md @@ -0,0 +1,19 @@ +--- +jsApi: true +title: "[F] isEventData" + +--- +```ts +function isEventData(program, type): boolean +``` + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `program` | `Program` | +| `type` | `ModelProperty` | + +## Returns + +`boolean` diff --git a/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/isEvents.md b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/isEvents.md new file mode 100644 index 0000000000..8304000715 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/functions/isEvents.md @@ -0,0 +1,19 @@ +--- +jsApi: true +title: "[F] isEvents" + +--- +```ts +function isEvents(program, type): boolean +``` + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `program` | `Program` | +| `type` | `Union` | + +## Returns + +`boolean` diff --git a/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/index.md b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/index.md new file mode 100644 index 0000000000..6d48fc8951 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/index.md @@ -0,0 +1,16 @@ +--- +jsApi: true +title: "[P] JS API" + +--- +## Variables + +- [$decorators](variables/$decorators.md) +- [$lib](variables/$lib.md) + +## Functions + +- [$onValidate](functions/$onValidate.md) +- [getContentType](functions/getContentType.md) +- [isEventData](functions/isEventData.md) +- [isEvents](functions/isEvents.md) diff --git a/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/variables/$decorators.md b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/variables/$decorators.md new file mode 100644 index 0000000000..c0066753dc --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/variables/$decorators.md @@ -0,0 +1,17 @@ +--- +jsApi: true +title: "[V] $decorators" + +--- +```ts +const $decorators: object; +``` + +## Type declaration + +| Name | Type | Default value | +| ------ | ------ | ------ | +| `TypeSpec.Events` | `object` | - | +| `TypeSpec.Events.contentType` | `ContentTypeDecorator` | $contentTypeDecorator | +| `TypeSpec.Events.data` | `DataDecorator` | $dataDecorator | +| `TypeSpec.Events.events` | `EventsDecorator` | $eventsDecorator | diff --git a/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/variables/$lib.md b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/variables/$lib.md new file mode 100644 index 0000000000..0371a6bd00 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/events/reference/js-api/variables/$lib.md @@ -0,0 +1,18 @@ +--- +jsApi: true +title: "[V] $lib" + +--- +```ts +const $lib: TypeSpecLibrary, "data" | "events" | "contentType">; +``` + +## Type declaration + +| Name | Type | +| ------ | ------ | +| `invalid-content-type-target` | `object` | +| `invalid-content-type-target.default` | `"@contentType can only be specified on the top-level event envelope, or the event payload marked with @data"` | +| `multiple-event-payloads` | `object` | +| `multiple-event-payloads.default` | `CallableMessage`<[`"dataPath"`, `"currentPath"`]\> | +| `multiple-event-payloads.payloadInIndexedModel` | `CallableMessage`<[`"dataPath"`]\> | diff --git a/packages/website/versioned_docs/version-latest/libraries/http/reference/js-api/index.md b/packages/website/versioned_docs/version-latest/libraries/http/reference/js-api/index.md index d096fa1aac..efcb844348 100644 --- a/packages/website/versioned_docs/version-latest/libraries/http/reference/js-api/index.md +++ b/packages/website/versioned_docs/version-latest/libraries/http/reference/js-api/index.md @@ -41,9 +41,9 @@ title: "[P] JS API" - [MetadataInfoOptions](interfaces/MetadataInfoOptions.md) - [NoAuth](interfaces/NoAuth.md) - [NoHttpAuthRef](interfaces/NoHttpAuthRef.md) +- [Oauth2Auth](interfaces/Oauth2Auth.md) - [OAuth2HttpAuthRef](interfaces/OAuth2HttpAuthRef.md) - [OAuth2Scope](interfaces/OAuth2Scope.md) -- [Oauth2Auth](interfaces/Oauth2Auth.md) - [OpenIDConnectAuth](interfaces/OpenIDConnectAuth.md) - [OperationParameterOptions](interfaces/OperationParameterOptions.md) - [PasswordFlow](interfaces/PasswordFlow.md) @@ -104,9 +104,9 @@ title: "[P] JS API" - [$sharedRoute](functions/$sharedRoute.md) - [$statusCode](functions/$statusCode.md) - [$useAuth](functions/$useAuth.md) -- [DefaultRouteProducer](functions/DefaultRouteProducer.md) - [addQueryParamsToUriTemplate](functions/addQueryParamsToUriTemplate.md) - [createMetadataInfo](functions/createMetadataInfo.md) +- [DefaultRouteProducer](functions/DefaultRouteProducer.md) - [getAllHttpServices](functions/getAllHttpServices.md) - [getAllRoutes](functions/getAllRoutes.md) - [getAuthentication](functions/getAuthentication.md) diff --git a/packages/website/versioned_docs/version-latest/libraries/sse/reference/data-types.md b/packages/website/versioned_docs/version-latest/libraries/sse/reference/data-types.md new file mode 100644 index 0000000000..d322877397 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/sse/reference/data-types.md @@ -0,0 +1,71 @@ +--- +title: "Data types" +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +# Data types + +## TypeSpec.SSE + +### `SSEStream` {#TypeSpec.SSE.SSEStream} + +Describes a stream of server-sent events. + +The content-type is set to `text/event-stream`. + +The server-sent events are described by `Type`. +The event type for any event can be defined by using named union variants. +When a union variant is not named, it is considered a 'message' event. + +```typespec +model TypeSpec.SSE.SSEStream +``` + +#### Template Parameters + +| Name | Description | +| ---- | ---------------------------------------------------- | +| Type | The set of models describing the server-sent events. | + +#### Examples + +##### Mix of named union variants and terminal event + +```typespec +model UserConnect { + username: string; + time: string; +} + +model UserMessage { + username: string; + time: string; + text: string; +} + +model UserDisconnect { + username: string; + time: string; +} + +@TypeSpec.Events.events +union ChannelEvents { + userconnect: UserConnect, + usermessage: UserMessage, + userdisconnect: UserDisconnect, + + @Events.contentType("text/plain") + @terminalEvent + "[unsubscribe]", +} + +op subscribeToChannel(): SSEStream; +``` + +#### Properties + +| Name | Type | Description | +| ----------- | --------------------- | ----------- | +| contentType | `"text/event-stream"` | | +| body | `string` | | diff --git a/packages/website/versioned_docs/version-latest/libraries/sse/reference/decorators.md b/packages/website/versioned_docs/version-latest/libraries/sse/reference/decorators.md new file mode 100644 index 0000000000..a92b00db99 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/sse/reference/decorators.md @@ -0,0 +1,26 @@ +--- +title: "Decorators" +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +# Decorators + +## TypeSpec.SSE + +### `@terminalEvent` {#@TypeSpec.SSE.terminalEvent} + +Indicates that the presence of this event is a terminal event, +and the client should disconnect from the server. + +```typespec +@TypeSpec.SSE.terminalEvent +``` + +#### Target + +`UnionVariant` + +#### Parameters + +None diff --git a/packages/website/versioned_docs/version-latest/libraries/sse/reference/index.mdx b/packages/website/versioned_docs/version-latest/libraries/sse/reference/index.mdx new file mode 100644 index 0000000000..fd60078eb0 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/sse/reference/index.mdx @@ -0,0 +1,42 @@ +--- +title: Overview +sidebar_position: 0 +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Overview + +TypeSpec library providing server sent events bindings + +## Install + + + + +```bash +npm install @typespec/sse +``` + + + + +```bash +npm install --save-peer @typespec/sse +``` + + + + +## TypeSpec.SSE + +### Decorators + +- [`@terminalEvent`](./decorators.md#@TypeSpec.SSE.terminalEvent) + +### Models + +- [`SSEStream`](./data-types.md#TypeSpec.SSE.SSEStream) diff --git a/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/_category_.json b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/_category_.json new file mode 100644 index 0000000000..bc91d15cee --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/_category_.json @@ -0,0 +1 @@ +{"label":"JS API","link":{"type":"doc","id":"index"}} \ No newline at end of file diff --git a/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/functions/$onValidate.md b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/functions/$onValidate.md new file mode 100644 index 0000000000..42cb14e224 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/functions/$onValidate.md @@ -0,0 +1,18 @@ +--- +jsApi: true +title: "[F] $onValidate" + +--- +```ts +function $onValidate(program): void +``` + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `program` | `Program` | + +## Returns + +`void` diff --git a/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/functions/isTerminalEvent.md b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/functions/isTerminalEvent.md new file mode 100644 index 0000000000..3768ba2b78 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/functions/isTerminalEvent.md @@ -0,0 +1,19 @@ +--- +jsApi: true +title: "[F] isTerminalEvent" + +--- +```ts +function isTerminalEvent(program, type): boolean +``` + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `program` | `Program` | +| `type` | `UnionVariant` | + +## Returns + +`boolean` diff --git a/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/index.md b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/index.md new file mode 100644 index 0000000000..936afed43c --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/index.md @@ -0,0 +1,14 @@ +--- +jsApi: true +title: "[P] JS API" + +--- +## Variables + +- [$decorators](variables/$decorators.md) +- [$lib](variables/$lib.md) + +## Functions + +- [$onValidate](functions/$onValidate.md) +- [isTerminalEvent](functions/isTerminalEvent.md) diff --git a/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/variables/$decorators.md b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/variables/$decorators.md new file mode 100644 index 0000000000..bb7ea97f70 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/variables/$decorators.md @@ -0,0 +1,15 @@ +--- +jsApi: true +title: "[V] $decorators" + +--- +```ts +const $decorators: object; +``` + +## Type declaration + +| Name | Type | Default value | +| ------ | ------ | ------ | +| `TypeSpec.SSE` | `object` | - | +| `TypeSpec.SSE.terminalEvent` | `TerminalEventDecorator` | $terminalEventDecorator | diff --git a/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/variables/$lib.md b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/variables/$lib.md new file mode 100644 index 0000000000..5aa5ba8c66 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/sse/reference/js-api/variables/$lib.md @@ -0,0 +1,15 @@ +--- +jsApi: true +title: "[V] $lib" + +--- +```ts +const $lib: TypeSpecLibrary, "terminalEvent">; +``` + +## Type declaration + +| Name | Type | Default value | +| ------ | ------ | ------ | +| `terminal-event-not-in-events` | `object` | - | +| `terminal-event-not-in-events.default` | `"A field marked as '@terminalEvent' must be a member of a type decorated with '@TpeSpec.Events.events'."` | "A field marked as '@terminalEvent' must be a member of a type decorated with '@TpeSpec.Events.events'." | diff --git a/packages/website/versioned_docs/version-latest/libraries/stream/reference/data-types.md b/packages/website/versioned_docs/version-latest/libraries/stream/reference/data-types.md new file mode 100644 index 0000000000..6b52f0434f --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/stream/reference/data-types.md @@ -0,0 +1,31 @@ +--- +title: "Data types" +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +# Data types + +## TypeSpec.Streams + +### `Stream` {#TypeSpec.Streams.Stream} + +Defines a model that represents a stream protocol type whose data is described +by `Type`. + +This can be useful when the underlying data type is not relevant, or to serve as +a base type for custom streams. + +```typespec +model TypeSpec.Streams.Stream +``` + +#### Template Parameters + +| Name | Description | +| ---- | ------------------------------ | +| Type | The type of the stream's data. | + +#### Properties + +None diff --git a/packages/website/versioned_docs/version-latest/libraries/stream/reference/decorators.md b/packages/website/versioned_docs/version-latest/libraries/stream/reference/decorators.md new file mode 100644 index 0000000000..7baec7a7bb --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/stream/reference/decorators.md @@ -0,0 +1,42 @@ +--- +title: "Decorators" +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +# Decorators + +## TypeSpec.Streams + +### `@streamOf` {#@TypeSpec.Streams.streamOf} + +Specify that a model represents a stream protocol type whose data is described +by `Type`. + +```typespec +@TypeSpec.Streams.streamOf(type: unknown) +``` + +#### Target + +`Model` + +#### Parameters + +| Name | Type | Description | +| ---- | --------- | ------------------------------------------------------- | +| type | `unknown` | The type that models the underlying data of the stream. | + +#### Examples + +```typespec +model Message { + id: string; + text: string; +} + +@streamOf(Message) +model Response { + @body body: string; +} +``` diff --git a/packages/website/versioned_docs/version-latest/libraries/stream/reference/index.mdx b/packages/website/versioned_docs/version-latest/libraries/stream/reference/index.mdx new file mode 100644 index 0000000000..854a1d24a3 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/stream/reference/index.mdx @@ -0,0 +1,42 @@ +--- +title: Overview +sidebar_position: 0 +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Overview + +TypeSpec library providing stream bindings + +## Install + + + + +```bash +npm install @typespec/streams +``` + + + + +```bash +npm install --save-peer @typespec/streams +``` + + + + +## TypeSpec.Streams + +### Decorators + +- [`@streamOf`](./decorators.md#@TypeSpec.Streams.streamOf) + +### Models + +- [`Stream`](./data-types.md#TypeSpec.Streams.Stream) diff --git a/packages/website/versioned_docs/version-latest/libraries/streams/reference/data-types.md b/packages/website/versioned_docs/version-latest/libraries/streams/reference/data-types.md new file mode 100644 index 0000000000..6b52f0434f --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/streams/reference/data-types.md @@ -0,0 +1,31 @@ +--- +title: "Data types" +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +# Data types + +## TypeSpec.Streams + +### `Stream` {#TypeSpec.Streams.Stream} + +Defines a model that represents a stream protocol type whose data is described +by `Type`. + +This can be useful when the underlying data type is not relevant, or to serve as +a base type for custom streams. + +```typespec +model TypeSpec.Streams.Stream +``` + +#### Template Parameters + +| Name | Description | +| ---- | ------------------------------ | +| Type | The type of the stream's data. | + +#### Properties + +None diff --git a/packages/website/versioned_docs/version-latest/libraries/streams/reference/decorators.md b/packages/website/versioned_docs/version-latest/libraries/streams/reference/decorators.md new file mode 100644 index 0000000000..7baec7a7bb --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/streams/reference/decorators.md @@ -0,0 +1,42 @@ +--- +title: "Decorators" +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +# Decorators + +## TypeSpec.Streams + +### `@streamOf` {#@TypeSpec.Streams.streamOf} + +Specify that a model represents a stream protocol type whose data is described +by `Type`. + +```typespec +@TypeSpec.Streams.streamOf(type: unknown) +``` + +#### Target + +`Model` + +#### Parameters + +| Name | Type | Description | +| ---- | --------- | ------------------------------------------------------- | +| type | `unknown` | The type that models the underlying data of the stream. | + +#### Examples + +```typespec +model Message { + id: string; + text: string; +} + +@streamOf(Message) +model Response { + @body body: string; +} +``` diff --git a/packages/website/versioned_docs/version-latest/libraries/streams/reference/index.mdx b/packages/website/versioned_docs/version-latest/libraries/streams/reference/index.mdx new file mode 100644 index 0000000000..854a1d24a3 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/streams/reference/index.mdx @@ -0,0 +1,42 @@ +--- +title: Overview +sidebar_position: 0 +toc_min_heading_level: 2 +toc_max_heading_level: 3 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Overview + +TypeSpec library providing stream bindings + +## Install + + + + +```bash +npm install @typespec/streams +``` + + + + +```bash +npm install --save-peer @typespec/streams +``` + + + + +## TypeSpec.Streams + +### Decorators + +- [`@streamOf`](./decorators.md#@TypeSpec.Streams.streamOf) + +### Models + +- [`Stream`](./data-types.md#TypeSpec.Streams.Stream) diff --git a/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/_category_.json b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/_category_.json new file mode 100644 index 0000000000..bc91d15cee --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/_category_.json @@ -0,0 +1 @@ +{"label":"JS API","link":{"type":"doc","id":"index"}} \ No newline at end of file diff --git a/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/functions/getStreamOf.md b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/functions/getStreamOf.md new file mode 100644 index 0000000000..66c8a8770a --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/functions/getStreamOf.md @@ -0,0 +1,19 @@ +--- +jsApi: true +title: "[F] getStreamOf" + +--- +```ts +function getStreamOf(program, type): undefined | Type +``` + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `program` | `Program` | +| `type` | `Model` | + +## Returns + +`undefined` \| `Type` diff --git a/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/functions/isStream.md b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/functions/isStream.md new file mode 100644 index 0000000000..b77f4980ca --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/functions/isStream.md @@ -0,0 +1,19 @@ +--- +jsApi: true +title: "[F] isStream" + +--- +```ts +function isStream(program, target): boolean +``` + +## Parameters + +| Parameter | Type | +| ------ | ------ | +| `program` | `Program` | +| `target` | `Model` | + +## Returns + +`boolean` diff --git a/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/index.md b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/index.md new file mode 100644 index 0000000000..8c2c4836bb --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/index.md @@ -0,0 +1,14 @@ +--- +jsApi: true +title: "[P] JS API" + +--- +## Variables + +- [$decorators](variables/$decorators.md) +- [$lib](variables/$lib.md) + +## Functions + +- [getStreamOf](functions/getStreamOf.md) +- [isStream](functions/isStream.md) diff --git a/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/variables/$decorators.md b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/variables/$decorators.md new file mode 100644 index 0000000000..ebf970ef8b --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/variables/$decorators.md @@ -0,0 +1,15 @@ +--- +jsApi: true +title: "[V] $decorators" + +--- +```ts +const $decorators: object; +``` + +## Type declaration + +| Name | Type | Default value | +| ------ | ------ | ------ | +| `TypeSpec.Streams` | `object` | - | +| `TypeSpec.Streams.streamOf` | `StreamOfDecorator` | $streamOfDecorator | diff --git a/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/variables/$lib.md b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/variables/$lib.md new file mode 100644 index 0000000000..a2774ad9b5 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/libraries/streams/reference/js-api/variables/$lib.md @@ -0,0 +1,8 @@ +--- +jsApi: true +title: "[V] $lib" + +--- +```ts +const $lib: TypeSpecLibrary, "streamOf">; +``` diff --git a/packages/website/versioned_docs/version-latest/release-notes/release-2024-10-09.md b/packages/website/versioned_docs/version-latest/release-notes/release-2024-10-09.md new file mode 100644 index 0000000000..bc8425df22 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/release-notes/release-2024-10-09.md @@ -0,0 +1,90 @@ +--- +title: 0.61 - October 2024 +--- + +:::warning +This release contains breaking changes +::: + +## Breaking Changes + +### @typespec/compiler + +- [#4539](https://github.com/microsoft/typespec/pull/4539) Config parameters and emitters options cannot contains `.`. This conflict with newly added support for nested options. +- [#4500](https://github.com/microsoft/typespec/pull/4500) API: Update default of `decoratorArgMarshalling` from `legacy` to `new` + +To revert to the old behavior export the following. **Highly discouraged, this will be removed in a few versions.** + +```ts +export const $flags = definePackageFlags({ + decoratorArgMarshalling: "legacy", +}); +``` + +- TypeSpec compiler expect the entrypoint to be an absolute path. This used to work with some alternative `CompilerHost` that handled relative path but this is no longer supported due to the new `exports` field support. + +## Features + +### @typespec/compiler + +- [#4442](https://github.com/microsoft/typespec/pull/4442) Library diagnostic can now define a `description` and `url` that links to a more detailed doc for this diagnostic +- [#4290](https://github.com/microsoft/typespec/pull/4290) Adding experimental (unstable) API fro Type Mutators +- [#4595](https://github.com/microsoft/typespec/pull/4595) Expose more accurate `PackageJson` type and deprecate `NodePackage` +- [#4606](https://github.com/microsoft/typespec/pull/4606) Add support for node `exports` field. Specific typespec exports can be provided with the `typespec` field + +```json +"exports": { + ".": { + "typespec": "./lib/main.tsp", + }, + "./named": { + "typespec": "./lib/named.tsp", + } +} +``` + +- [#4539](https://github.com/microsoft/typespec/pull/4539) Support nested emitter options + +### @typespec/http + +- [#4513](https://github.com/microsoft/typespec/pull/4513) Adds HttpStream and JsonlStream models to to support streaming use-cases. + +### @typespec/openapi3 + +- [#4423](https://github.com/microsoft/typespec/pull/4423) Added support to use Scalar and Object as default types + +### @typespec/json-schema + +- [#4447](https://github.com/microsoft/typespec/pull/4447) Example set with `@example` decorator will populate the schema `examples` property + +### typespec-vscode + +- [#4330](https://github.com/microsoft/typespec/pull/4330) Support Compile Task and Watch Task in vscode. +- [#4498](https://github.com/microsoft/typespec/pull/4498) Make extension web compatible with minimal functionality + +## Bug Fixes + +### @typespec/compiler + +- [#4513](https://github.com/microsoft/typespec/pull/4513) Fixes issue with the semantic walker where `exitTuple` was not being emitted. +- [#4462](https://github.com/microsoft/typespec/pull/4462) Fix examples with enums inside of unions +- [#4574](https://github.com/microsoft/typespec/pull/4574) Fix: Passing `const` of model type to `@example` +- [#4551](https://github.com/microsoft/typespec/pull/4551) Json serialization of example respect `@encodedName` +- [#4514](https://github.com/microsoft/typespec/pull/4514) Fix issue with decimal numeric and leading `0.0` with multiple digit +- [#4445](https://github.com/microsoft/typespec/pull/4445) [API] model `sourceModels` property are now projected correctly +- [#4467](https://github.com/microsoft/typespec/pull/4467) Changing tspconfig.yaml won't take effect in LSP server because of the cache +- [#4563](https://github.com/microsoft/typespec/pull/4563) `tsp compile --watch` reread from `tspconfig.yaml` file +- [#4626](https://github.com/microsoft/typespec/pull/4626) [API] Add missing exit callback + +### @typespec/openapi + +- [#4505](https://github.com/microsoft/typespec/pull/4505) `@info` decorator validate no extra properties not starting with `x-` are provided. +- [#4483](https://github.com/microsoft/typespec/pull/4483) `@info` decorator validate `termsOfService` is a valid url + +### @typespec/internal-build-utils + +- [#4498](https://github.com/microsoft/typespec/pull/4498) Ignore test from third party notice generation + +### typespec-vscode + +- [#4430](https://github.com/microsoft/typespec/pull/4430) Use "shell" when spawning execution of .cmd file(i.e. tsp-server.cmd) in windows diff --git a/packages/website/versioned_docs/version-latest/standard-library/diags/triple-quote-indent.md b/packages/website/versioned_docs/version-latest/standard-library/diags/triple-quote-indent.md new file mode 100644 index 0000000000..794dbc3626 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/standard-library/diags/triple-quote-indent.md @@ -0,0 +1,25 @@ +--- +title: triple-quote-indent +--- + +Triple quoted strings must all be at least indented to the same level as closing `"""`. + +#### ❌ Incorrect + +```tsp +const a = """ +one + two + """; +``` + +#### ✅ Correct + +```tsp +const a = """ + one + two + """; +``` + +This would result in the following string `"one\n two\n"`. diff --git a/packages/website/versioned_docs/version-latest/standard-library/examples.md b/packages/website/versioned_docs/version-latest/standard-library/examples.md index afbfaccffb..7ee382b624 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/examples.md +++ b/packages/website/versioned_docs/version-latest/standard-library/examples.md @@ -65,6 +65,18 @@ model Pet { } ``` +### Define typed examples using `const` + +```tsp +const petExample: Pet = #{ name: "Max", age: 3 }; + +@example(petExample) +model Pet { + name: string; + age: int32; +} +``` + ## Operation examples Operation example are provided with the `@opExample` decorator. Similar to the `@example` decorator the first argument is the example value however it takes both the `parameters` and `returnType` example. diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/classes/DuplicateTracker.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/classes/DuplicateTracker.md index baa149a44c..49402e7442 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/classes/DuplicateTracker.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/classes/DuplicateTracker.md @@ -29,14 +29,14 @@ new DuplicateTracker(): DuplicateTracker ### entries() ```ts -entries(): Iterable<[K, V[]]> +entries(): Iterable<[K, V[]], any, any> ``` Return iterator of all the duplicate entries. #### Returns -`Iterable`<[`K`, `V`[]]\> +`Iterable`<[`K`, `V`[]], `any`, `any`\> *** diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/enumerations/Token.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/enumerations/Token.md index 4e9d6a9010..70b09b710a 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/enumerations/Token.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/enumerations/Token.md @@ -63,10 +63,10 @@ title: "[E] Token" | `NewLine` | `11` | | `None` | `0` | | `NumericLiteral` | `4` | -| `OpKeyword` | `57` | | `OpenBrace` | `17` | | `OpenBracket` | `21` | | `OpenParen` | `19` | +| `OpKeyword` | `57` | | `Plus` | `42` | | `ProjectionKeyword` | `63` | | `Question` | `32` | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/checkFormatCadl.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/checkFormatCadl.md index 353c73c399..551d554131 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/checkFormatCadl.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/checkFormatCadl.md @@ -18,6 +18,8 @@ function checkFormatCadl(code, prettierConfig?): Promise `Promise`<`boolean`\> +true if code is formatted correctly. + ## Deprecated use checkFormatTypeSpec diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/createCadlLibrary.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/createCadlLibrary.md index 5ccd217e75..7cd85584a2 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/createCadlLibrary.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/createCadlLibrary.md @@ -25,6 +25,25 @@ function createCadlLibrary(lib): TypeSpecLibrary [`TypeSpecLibrary`](../interfaces/TypeSpecLibrary.md)<`T`, `E`, `State`\> +Library with utility functions. + ## Deprecated use createTypeSpecLibrary + +## Tutorial + +Create the lib object with `as const` to get the full typing. + +## Example + +```ts +const libDef = { + name: "myLib", + diagnostics: { + "my-code": {serverity: "error", messages: {default: "Foo bar"}} + }, +} as const; + +const lib = createTypeSpecLibrary(libDef); +``` diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getEncode.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getEncode.md index 92e5aba31c..6583a295e8 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getEncode.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getEncode.md @@ -4,7 +4,7 @@ title: "[F] getEncode" --- ```ts -function getEncode(program, target): EncodeData | undefined +function getEncode(program, type): undefined | EncodeData ``` ## Parameters @@ -12,8 +12,8 @@ function getEncode(program, target): EncodeData | undefined | Parameter | Type | | ------ | ------ | | `program` | [`Program`](../interfaces/Program.md) | -| `target` | [`ModelProperty`](../interfaces/ModelProperty.md) \| [`Scalar`](../interfaces/Scalar.md) | +| `type` | [`ModelProperty`](../interfaces/ModelProperty.md) \| [`Scalar`](../interfaces/Scalar.md) | ## Returns -[`EncodeData`](../interfaces/EncodeData.md) \| `undefined` +`undefined` \| [`EncodeData`](../interfaces/EncodeData.md) diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getFormat.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getFormat.md index ef3b1fc08d..8e9593a1aa 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getFormat.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getFormat.md @@ -4,7 +4,7 @@ title: "[F] getFormat" --- ```ts -function getFormat(program, target): string | undefined +function getFormat(program, type): undefined | string ``` ## Parameters @@ -12,8 +12,8 @@ function getFormat(program, target): string | undefined | Parameter | Type | | ------ | ------ | | `program` | [`Program`](../interfaces/Program.md) | -| `target` | [`Type`](../type-aliases/Type.md) | +| `type` | [`Type`](../type-aliases/Type.md) | ## Returns -`string` \| `undefined` +`undefined` \| `string` diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getFriendlyName.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getFriendlyName.md index a4eb4c881e..334331650f 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getFriendlyName.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getFriendlyName.md @@ -4,7 +4,7 @@ title: "[F] getFriendlyName" --- ```ts -function getFriendlyName(program, target): string +function getFriendlyName(program, type): undefined | string ``` ## Parameters @@ -12,8 +12,8 @@ function getFriendlyName(program, target): string | Parameter | Type | | ------ | ------ | | `program` | [`Program`](../interfaces/Program.md) | -| `target` | [`Type`](../type-aliases/Type.md) | +| `type` | [`Type`](../type-aliases/Type.md) | ## Returns -`string` +`undefined` \| `string` diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getKeyName.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getKeyName.md index ab907b95df..b3d0a44954 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getKeyName.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getKeyName.md @@ -4,7 +4,7 @@ title: "[F] getKeyName" --- ```ts -function getKeyName(program, property): string +function getKeyName(program, property): string | undefined ``` ## Parameters @@ -16,4 +16,4 @@ function getKeyName(program, property): string ## Returns -`string` +`string` \| `undefined` diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getKnownValues.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getKnownValues.md index 054feb1151..f6dd624b4b 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getKnownValues.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getKnownValues.md @@ -4,7 +4,7 @@ title: "[F] getKnownValues" --- ```ts -function getKnownValues(program, target): Enum | undefined +function getKnownValues(program, type): undefined | Enum ``` ## Parameters @@ -12,8 +12,8 @@ function getKnownValues(program, target): Enum | undefined | Parameter | Type | | ------ | ------ | | `program` | [`Program`](../interfaces/Program.md) | -| `target` | [`ModelProperty`](../interfaces/ModelProperty.md) \| [`Scalar`](../interfaces/Scalar.md) | +| `type` | [`Type`](../type-aliases/Type.md) | ## Returns -[`Enum`](../interfaces/Enum.md) \| `undefined` +`undefined` \| [`Enum`](../interfaces/Enum.md) diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getOverloadedOperation.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getOverloadedOperation.md index 552a593274..669354ba4e 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getOverloadedOperation.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getOverloadedOperation.md @@ -4,20 +4,16 @@ title: "[F] getOverloadedOperation" --- ```ts -function getOverloadedOperation(program, operation): Operation | undefined +function getOverloadedOperation(program, type): undefined | Operation ``` -If the given operation overloads another operation, return that operation. - ## Parameters -| Parameter | Type | Description | -| ------ | ------ | ------ | -| `program` | [`Program`](../interfaces/Program.md) | Program | -| `operation` | [`Operation`](../interfaces/Operation.md) | The operation to check for an overload target. | +| Parameter | Type | +| ------ | ------ | +| `program` | [`Program`](../interfaces/Program.md) | +| `type` | [`Operation`](../interfaces/Operation.md) | ## Returns -[`Operation`](../interfaces/Operation.md) \| `undefined` - -The operation this operation overloads, if any. +`undefined` \| [`Operation`](../interfaces/Operation.md) diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getOverloads.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getOverloads.md index 6a301c2e97..462a05428c 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getOverloads.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getOverloads.md @@ -4,20 +4,16 @@ title: "[F] getOverloads" --- ```ts -function getOverloads(program, operation): Operation[] | undefined +function getOverloads(program, type): undefined | Operation[] ``` -Get all operations that are marked as overloads of the given operation - ## Parameters -| Parameter | Type | Description | -| ------ | ------ | ------ | -| `program` | [`Program`](../interfaces/Program.md) | Program | -| `operation` | [`Operation`](../interfaces/Operation.md) | Operation | +| Parameter | Type | +| ------ | ------ | +| `program` | [`Program`](../interfaces/Program.md) | +| `type` | [`Operation`](../interfaces/Operation.md) | ## Returns -[`Operation`](../interfaces/Operation.md)[] \| `undefined` - -An array of operations that overload the given operation. +`undefined` \| [`Operation`](../interfaces/Operation.md)[] diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getParameterVisibility.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getParameterVisibility.md index d35acc4ba3..aad949409b 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getParameterVisibility.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getParameterVisibility.md @@ -4,22 +4,16 @@ title: "[F] getParameterVisibility" --- ```ts -function getParameterVisibility(program, entity): string[] | undefined +function getParameterVisibility(program, type): undefined | string[] ``` -Returns the visibilities of the parameters of the given operation, if provided with `@parameterVisibility`. - ## Parameters | Parameter | Type | | ------ | ------ | | `program` | [`Program`](../interfaces/Program.md) | -| `entity` | [`Operation`](../interfaces/Operation.md) | +| `type` | [`Type`](../type-aliases/Type.md) | ## Returns -`string`[] \| `undefined` - -## See - -[$parameterVisibility]($parameterVisibility.md) +`undefined` \| `string`[] diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getPatternData.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getPatternData.md index 75f6df6b66..97dc72e9a6 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getPatternData.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getPatternData.md @@ -4,21 +4,16 @@ title: "[F] getPatternData" --- ```ts -function getPatternData(program, target): PatternData | undefined +function getPatternData(program, type): undefined | PatternData ``` -Gets the associated pattern data, including the pattern regular expression and optional validation message, if any -has been set. - ## Parameters -| Parameter | Type | Description | -| ------ | ------ | ------ | -| `program` | [`Program`](../interfaces/Program.md) | the Program containing the target Type | -| `target` | [`Type`](../type-aliases/Type.md) | the type to get the pattern data for | +| Parameter | Type | +| ------ | ------ | +| `program` | [`Program`](../interfaces/Program.md) | +| `type` | [`Type`](../type-aliases/Type.md) | ## Returns -[`PatternData`](../interfaces/PatternData.md) \| `undefined` - -the pattern data, if any was set +`undefined` \| [`PatternData`](../interfaces/PatternData.md) diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getReturnTypeVisibility.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getReturnTypeVisibility.md index e45612fd99..0f56a668a6 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getReturnTypeVisibility.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getReturnTypeVisibility.md @@ -4,22 +4,16 @@ title: "[F] getReturnTypeVisibility" --- ```ts -function getReturnTypeVisibility(program, entity): string[] | undefined +function getReturnTypeVisibility(program, type): undefined | string[] ``` -Returns the visibilities of the return type of the given operation, if provided with `@returnTypeVisibility`. - ## Parameters | Parameter | Type | | ------ | ------ | | `program` | [`Program`](../interfaces/Program.md) | -| `entity` | [`Operation`](../interfaces/Operation.md) | +| `type` | [`Type`](../type-aliases/Type.md) | ## Returns -`string`[] \| `undefined` - -## See - -[$returnTypeVisibility]($returnTypeVisibility.md) +`undefined` \| `string`[] diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getService.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getService.md index befc7ff73d..eb677ba58d 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getService.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getService.md @@ -4,20 +4,16 @@ title: "[F] getService" --- ```ts -function getService(program, namespace): Service | undefined +function getService(program, type): undefined | Service ``` -Get the service information for the given namespace. - ## Parameters -| Parameter | Type | Description | -| ------ | ------ | ------ | -| `program` | [`Program`](../interfaces/Program.md) | Program | -| `namespace` | [`Namespace`](../interfaces/Namespace.md) | Service namespace | +| Parameter | Type | +| ------ | ------ | +| `program` | [`Program`](../interfaces/Program.md) | +| `type` | [`Namespace`](../interfaces/Namespace.md) | ## Returns -[`Service`](../interfaces/Service.md) \| `undefined` - -Service information or undefined if namespace is not a service namespace. +`undefined` \| [`Service`](../interfaces/Service.md) diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getSummary.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getSummary.md index 40a7262dfe..5467f4dc2b 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getSummary.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getSummary.md @@ -4,7 +4,7 @@ title: "[F] getSummary" --- ```ts -function getSummary(program, type): string | undefined +function getSummary(program, type): undefined | string ``` ## Parameters @@ -16,4 +16,4 @@ function getSummary(program, type): string | undefined ## Returns -`string` \| `undefined` +`undefined` \| `string` diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getVisibility.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getVisibility.md index 338d1f77f9..bd699c3931 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getVisibility.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/getVisibility.md @@ -4,7 +4,7 @@ title: "[F] getVisibility" --- ```ts -function getVisibility(program, target): string[] | undefined +function getVisibility(program, type): undefined | string[] ``` ## Parameters @@ -12,8 +12,8 @@ function getVisibility(program, target): string[] | undefined | Parameter | Type | | ------ | ------ | | `program` | [`Program`](../interfaces/Program.md) | -| `target` | [`Type`](../type-aliases/Type.md) | +| `type` | [`Type`](../type-aliases/Type.md) | ## Returns -`string`[] \| `undefined` +`undefined` \| `string`[] diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/isCadlValueTypeOf.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/isCadlValueTypeOf.md index b52b83202b..cd01e90545 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/isCadlValueTypeOf.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/isCadlValueTypeOf.md @@ -24,6 +24,8 @@ function isCadlValueTypeOf(target, expectedType): target is InferredTypeSpecV `target is InferredTypeSpecValue` +boolean if the target is of one of the allowed types. + ## Deprecated use isTypeSpecValueTypeOf diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/isSecret.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/isSecret.md index 7647ae8e29..737878222b 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/isSecret.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/isSecret.md @@ -4,7 +4,7 @@ title: "[F] isSecret" --- ```ts -function isSecret(program, target): boolean | undefined +function isSecret(program, type): boolean ``` ## Parameters @@ -12,8 +12,8 @@ function isSecret(program, target): boolean | undefined | Parameter | Type | | ------ | ------ | | `program` | [`Program`](../interfaces/Program.md) | -| `target` | [`Type`](../type-aliases/Type.md) | +| `type` | [`Type`](../type-aliases/Type.md) | ## Returns -`boolean` \| `undefined` +`boolean` diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/resolveModule.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/resolveModule.md index ee764c29fe..8a93510f94 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/resolveModule.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/functions/resolveModule.md @@ -6,7 +6,7 @@ title: "[F] resolveModule" ```ts function resolveModule( host, - name, + specifier, options): Promise ``` @@ -17,9 +17,13 @@ Resolve a module | Parameter | Type | Description | | ------ | ------ | ------ | | `host` | [`ResolveModuleHost`](../interfaces/ResolveModuleHost.md) | | -| `name` | `string` | | +| `specifier` | `string` | | | `options` | [`ResolveModuleOptions`](../interfaces/ResolveModuleOptions.md) | | ## Returns `Promise`<[`ModuleResolutionResult`](../type-aliases/ModuleResolutionResult.md)\> + +## Throws + +When the module cannot be resolved. diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/index.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/index.md index 318d051186..3f853d5ff7 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/index.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/index.md @@ -5,6 +5,12 @@ title: "[P] JS API" --- ## References +### ~~NodePackage~~ + +Renames and re-exports [PackageJson](interfaces/PackageJson.md) + +*** + ### printIdentifier Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) @@ -45,8 +51,8 @@ Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) - [BooleanLiteral](interfaces/BooleanLiteral.md) - [BooleanLiteralNode](interfaces/BooleanLiteralNode.md) - [BooleanValue](interfaces/BooleanValue.md) -- [CallExpressionNode](interfaces/CallExpressionNode.md) - [CallableMessage](interfaces/CallableMessage.md) +- [CallExpressionNode](interfaces/CallExpressionNode.md) - [Checker](interfaces/Checker.md) - [CodeFix](interfaces/CodeFix.md) - [CodeFixContext](interfaces/CodeFixContext.md) @@ -132,9 +138,9 @@ Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) - [LinterRuleDefinition](interfaces/LinterRuleDefinition.md) - [LinterRuleSet](interfaces/LinterRuleSet.md) - [ListOperationOptions](interfaces/ListOperationOptions.md) +- [Logger](interfaces/Logger.md) - [LogInfo](interfaces/LogInfo.md) - [LogSink](interfaces/LogSink.md) -- [Logger](interfaces/Logger.md) - [MemberExpressionNode](interfaces/MemberExpressionNode.md) - [MixedFunctionParameter](interfaces/MixedFunctionParameter.md) - [MixedParameterConstraint](interfaces/MixedParameterConstraint.md) @@ -151,7 +157,6 @@ Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) - [NavigationOptions](interfaces/NavigationOptions.md) - [NeverKeywordNode](interfaces/NeverKeywordNode.md) - [NeverType](interfaces/NeverType.md) -- [NodePackage](interfaces/NodePackage.md) - [NullType](interfaces/NullType.md) - [NullValue](interfaces/NullValue.md) - [Numeric](interfaces/Numeric.md) @@ -164,18 +169,18 @@ Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) - [ObjectType](interfaces/ObjectType.md) - [ObjectValue](interfaces/ObjectValue.md) - [ObjectValuePropertyDescriptor](interfaces/ObjectValuePropertyDescriptor.md) -- [OpExample](interfaces/OpExample.md) - [Operation](interfaces/Operation.md) - [OperationSignatureDeclarationNode](interfaces/OperationSignatureDeclarationNode.md) - [OperationSignatureReferenceNode](interfaces/OperationSignatureReferenceNode.md) - [OperationStatementNode](interfaces/OperationStatementNode.md) +- [OpExample](interfaces/OpExample.md) - [PackageFlags](interfaces/PackageFlags.md) +- [PackageJson](interfaces/PackageJson.md) - [ParseOptions](interfaces/ParseOptions.md) - [PatternData](interfaces/PatternData.md) - [PositionDetail](interfaces/PositionDetail.md) - [ProcessedLog](interfaces/ProcessedLog.md) - [Program](interfaces/Program.md) -- [ProjectLocationContext](interfaces/ProjectLocationContext.md) - [ProjectedNameView](interfaces/ProjectedNameView.md) - [ProjectedProgram](interfaces/ProjectedProgram.md) - [Projection](interfaces/Projection.md) @@ -210,14 +215,15 @@ Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) - [ProjectionUnaryExpressionNode](interfaces/ProjectionUnaryExpressionNode.md) - [ProjectionUnionSelectorNode](interfaces/ProjectionUnionSelectorNode.md) - [ProjectionUnionVariantSelectorNode](interfaces/ProjectionUnionVariantSelectorNode.md) +- [ProjectLocationContext](interfaces/ProjectLocationContext.md) - [Projector](interfaces/Projector.md) - [RecordModelType](interfaces/RecordModelType.md) - [ReplaceTextCodeFixEdit](interfaces/ReplaceTextCodeFixEdit.md) - [ResolveCompilerOptionsOptions](interfaces/ResolveCompilerOptionsOptions.md) -- [ResolveModuleHost](interfaces/ResolveModuleHost.md) -- [ResolveModuleOptions](interfaces/ResolveModuleOptions.md) - [ResolvedFile](interfaces/ResolvedFile.md) - [ResolvedModule](interfaces/ResolvedModule.md) +- [ResolveModuleHost](interfaces/ResolveModuleHost.md) +- [ResolveModuleOptions](interfaces/ResolveModuleOptions.md) - [ReturnExpressionNode](interfaces/ReturnExpressionNode.md) - [ReturnRecord](interfaces/ReturnRecord.md) - [RmOptions](interfaces/RmOptions.md) @@ -259,9 +265,9 @@ Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) - [SyntheticLocationContext](interfaces/SyntheticLocationContext.md) - [TemplateArgumentNode](interfaces/TemplateArgumentNode.md) - [TemplateDeclarationNode](interfaces/TemplateDeclarationNode.md) +- [TemplatedTypeBase](interfaces/TemplatedTypeBase.md) - [TemplateParameter](interfaces/TemplateParameter.md) - [TemplateParameterDeclarationNode](interfaces/TemplateParameterDeclarationNode.md) -- [TemplatedTypeBase](interfaces/TemplatedTypeBase.md) - [TextRange](interfaces/TextRange.md) - [Tracer](interfaces/Tracer.md) - [TracerOptions](interfaces/TracerOptions.md) @@ -377,15 +383,15 @@ Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) ## Variables -- [CadlPrettierPlugin](variables/CadlPrettierPlugin.md) -- [MANIFEST](variables/MANIFEST.md) -- [NoTarget](variables/NoTarget.md) -- [NodeHost](variables/NodeHost.md) -- [TypeSpecPrettierPlugin](variables/TypeSpecPrettierPlugin.md) - [altDirectorySeparator](variables/altDirectorySeparator.md) +- [CadlPrettierPlugin](variables/CadlPrettierPlugin.md) - [cadlVersion](variables/cadlVersion.md) - [directorySeparator](variables/directorySeparator.md) +- [MANIFEST](variables/MANIFEST.md) - [namespace](variables/namespace.md) +- [NodeHost](variables/NodeHost.md) +- [NoTarget](variables/NoTarget.md) +- [TypeSpecPrettierPlugin](variables/TypeSpecPrettierPlugin.md) - [typespecVersion](variables/typespecVersion.md) ## Functions @@ -417,8 +423,8 @@ Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) - [$parameterVisibility](functions/$parameterVisibility.md) - [$pattern](functions/$pattern.md) - [$projectedName](functions/$projectedName.md) -- [$returnTypeVisibility](functions/$returnTypeVisibility.md) - [$returnsDoc](functions/$returnsDoc.md) +- [$returnTypeVisibility](functions/$returnTypeVisibility.md) - [$secret](functions/$secret.md) - [$service](functions/$service.md) - [$summary](functions/$summary.md) @@ -426,12 +432,11 @@ Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) - [$visibility](functions/$visibility.md) - [$withDefaultKeyVisibility](functions/$withDefaultKeyVisibility.md) - [$withOptionalProperties](functions/$withOptionalProperties.md) +- [$withoutDefaultValues](functions/$withoutDefaultValues.md) +- [$withoutOmittedProperties](functions/$withoutOmittedProperties.md) - [$withPickedProperties](functions/$withPickedProperties.md) - [$withUpdateableProperties](functions/$withUpdateableProperties.md) - [$withVisibility](functions/$withVisibility.md) -- [$withoutDefaultValues](functions/$withoutDefaultValues.md) -- [$withoutOmittedProperties](functions/$withoutOmittedProperties.md) -- [Numeric](functions/Numeric.md) - [addService](functions/addService.md) - [assertType](functions/assertType.md) - [cadlTypeToJson](functions/cadlTypeToJson.md) @@ -526,9 +531,9 @@ Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) - [getProperty](functions/getProperty.md) - [getPropertyType](functions/getPropertyType.md) - [getRelativePathFromDirectory](functions/getRelativePathFromDirectory.md) -- [getReturnTypeVisibility](functions/getReturnTypeVisibility.md) - [getReturnsDoc](functions/getReturnsDoc.md) - [getReturnsDocData](functions/getReturnsDocData.md) +- [getReturnTypeVisibility](functions/getReturnTypeVisibility.md) - [getRootLength](functions/getRootLength.md) - [getService](functions/getService.md) - [getSourceFileKindFromExt](functions/getSourceFileKindFromExt.md) @@ -594,6 +599,7 @@ Renames and re-exports [formatIdentifier](functions/formatIdentifier.md) - [navigateTypesInNamespace](functions/navigateTypesInNamespace.md) - [normalizePath](functions/normalizePath.md) - [normalizeSlashes](functions/normalizeSlashes.md) +- [Numeric](functions/Numeric.md) - [paramMessage](functions/paramMessage.md) - [parse](functions/parse.md) - [parseStandaloneTypeReference](functions/parseStandaloneTypeReference.md) diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/DecoratorArgument.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/DecoratorArgument.md index 92c6b004b6..801280f97c 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/DecoratorArgument.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/DecoratorArgument.md @@ -7,6 +7,6 @@ title: "[I] DecoratorArgument" | Property | Type | Description | | ------ | ------ | ------ | -| `jsValue` | \| `null` \| `string` \| `number` \| `boolean` \| `unknown`[] \| [`Numeric`](Numeric.md) \| [`Type`](../type-aliases/Type.md) \| `Record`<`string`, `unknown`\> \| [`Value`](../type-aliases/Value.md) | Marshalled value for use in Javascript. | +| `jsValue` | \| `null` \| `string` \| `number` \| `boolean` \| `unknown`[] \| `Record`<`string`, `unknown`\> \| [`Numeric`](Numeric.md) \| [`Type`](../type-aliases/Type.md) \| [`Value`](../type-aliases/Value.md) | Marshalled value for use in Javascript. | | `node?` | [`Node`](../type-aliases/Node.md) | - | | `value` | [`Type`](../type-aliases/Type.md) \| [`Value`](../type-aliases/Value.md) | - | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/DiagnosticDefinition.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/DiagnosticDefinition.md index 53fb59e6f4..ae8b3ea709 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/DiagnosticDefinition.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/DiagnosticDefinition.md @@ -3,6 +3,21 @@ jsApi: true title: "[I] DiagnosticDefinition" --- +Declare a diagnostic that can be reported by the library. + +## Example + +```ts +unterminated: { + severity: "error", + description: "Unterminated token.", + url: "https://example.com/docs/diags/unterminated", + messages: { + default: paramMessage`Unterminated ${"token"}.`, + }, +}, +``` + ## Type Parameters | Type Parameter | @@ -11,7 +26,9 @@ title: "[I] DiagnosticDefinition" ## Properties -| Property | Modifier | Type | -| ------ | ------ | ------ | -| `messages` | `readonly` | `M` | -| `severity` | `readonly` | `"error"` \| `"warning"` | +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `description?` | `readonly` | `string` | Short description of the diagnostic | +| `messages` | `readonly` | `M` | Messages that can be reported with the diagnostic. | +| `severity` | `readonly` | `"error"` \| `"warning"` | Diagnostic severity. - `warning` - Suppressable, should be used to represent potential issues but not blocking. - `error` - Non-suppressable, should be used to represent failure to move forward. | +| `url?` | `readonly` | `string` | Specifies the URL at which the full documentation can be accessed. | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/IntrinsicType.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/IntrinsicType.md index 2256912e41..6423e51028 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/IntrinsicType.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/IntrinsicType.md @@ -23,7 +23,7 @@ title: "[I] IntrinsicType" | `instantiationParameters?` | `public` | [`Type`](../type-aliases/Type.md)[] | - | - | [`BaseType`](BaseType.md).`instantiationParameters` | | `isFinished` | `public` | `boolean` | Reflect if a type has been finished(Decorators have been called). There is multiple reasons a type might not be finished: - a template declaration will not - a template instance that argument that are still template parameters - a template instance that is only partially instantiated(like a templated operation inside a templated interface) | - | [`BaseType`](BaseType.md).`isFinished` | | `kind` | `public` | `"Intrinsic"` | - | [`BaseType`](BaseType.md).`kind` | - | -| `name` | `public` | \| `"unknown"` \| `"never"` \| `"null"` \| `"ErrorType"` \| `"void"` | - | - | - | +| `name` | `public` | \| `"unknown"` \| `"never"` \| `"null"` \| `"void"` \| `"ErrorType"` | - | - | - | | `node?` | `public` | [`Node`](../type-aliases/Node.md) | - | - | [`BaseType`](BaseType.md).`node` | | `projectionBase?` | `public` | [`Type`](../type-aliases/Type.md) | - | - | [`BaseType`](BaseType.md).`projectionBase` | | `projectionSource?` | `public` | [`Type`](../type-aliases/Type.md) | - | - | [`BaseType`](BaseType.md).`projectionSource` | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/LinterDefinition.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/LinterDefinition.md index a9a46ea5c6..5e448f6a41 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/LinterDefinition.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/LinterDefinition.md @@ -7,5 +7,5 @@ title: "[I] LinterDefinition" | Property | Type | | ------ | ------ | -| `ruleSets?` | `Record`<`string`, [`LinterRuleSet`](LinterRuleSet.md)\> | | `rules` | [`LinterRuleDefinition`](LinterRuleDefinition.md)<`string`, [`DiagnosticMessages`](DiagnosticMessages.md)\>[] | +| `ruleSets?` | `Record`<`string`, [`LinterRuleSet`](LinterRuleSet.md)\> | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/LinterResolvedDefinition.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/LinterResolvedDefinition.md index 3060bbed5d..3e73921686 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/LinterResolvedDefinition.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/LinterResolvedDefinition.md @@ -7,5 +7,5 @@ title: "[I] LinterResolvedDefinition" | Property | Modifier | Type | | ------ | ------ | ------ | -| `ruleSets` | `readonly` | `object` | | `rules` | `readonly` | [`LinterRule`](LinterRule.md)<`string`, [`DiagnosticMessages`](DiagnosticMessages.md)\>[] | +| `ruleSets` | `readonly` | `object` | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/NodePackage.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/NodePackage.md deleted file mode 100644 index 01fc31cf1a..0000000000 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/NodePackage.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -jsApi: true -title: "[I] NodePackage" - ---- -Type for package.json https://docs.npmjs.com/cli/v8/configuring-npm/package-json - -## Properties - -| Property | Type | -| ------ | ------ | -| `bugs?` | `object` | -| `bugs.email?` | `string` | -| `bugs.url?` | `string` | -| `dependencies?` | `Record`<`string`, `string`\> | -| `description?` | `string` | -| `devDependencies?` | `Record`<`string`, `string`\> | -| `homepage?` | `string` | -| `main?` | `string` | -| `name` | `string` | -| `peerDependencies?` | `Record`<`string`, `string`\> | -| `private?` | `boolean` | -| `tspMain?` | `string` | -| `type?` | `"module"` \| `"commonjs"` | -| `version` | `string` | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/PackageFlags.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/PackageFlags.md index c974386702..ef97858011 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/PackageFlags.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/PackageFlags.md @@ -7,4 +7,4 @@ title: "[I] PackageFlags" | Property | Modifier | Type | Description | | ------ | ------ | ------ | ------ | -| `decoratorArgMarshalling?` | `readonly` | `"new"` \| `"legacy"` | Decorator arg marshalling algorithm. Specify how TypeSpec values are marshalled to decorator arguments. - `lossless` - New recommended behavior - string value -> `string` - numeric value -> `number` if the constraint can be represented as a JS number, Numeric otherwise(e.g. for types int64, decimal128, numeric, etc.) - boolean value -> `boolean` - null value -> `null` - `legacy` Behavior before version 0.56.0. - string value -> `string` - numeric value -> `number` - boolean value -> `boolean` - null value -> `NullType` **Default** `legacy` | +| `decoratorArgMarshalling?` | `readonly` | `"new"` \| `"legacy"` | Decorator arg marshalling algorithm. Specify how TypeSpec values are marshalled to decorator arguments. - `new` - New recommended behavior - string value -> `string` - numeric value -> `number` if the constraint can be represented as a JS number, Numeric otherwise(e.g. for types int64, decimal128, numeric, etc.) - boolean value -> `boolean` - null value -> `null` - `legacy` - DEPRECATED - Behavior before version 0.56.0. - string value -> `string` - numeric value -> `number` - boolean value -> `boolean` - null value -> `NullType` **Default** `new` | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/PackageJson.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/PackageJson.md new file mode 100644 index 0000000000..5ce9551387 --- /dev/null +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/PackageJson.md @@ -0,0 +1,26 @@ +--- +jsApi: true +title: "[I] PackageJson" + +--- +Type for package.json https://docs.npmjs.com/cli/configuring-npm/package-json + +## Properties + +| Property | Type | Description | +| ------ | ------ | ------ | +| `bugs?` | `object` | - | +| `bugs.email?` | `string` | - | +| `bugs.url?` | `string` | - | +| `dependencies?` | `Record`<`string`, `string`\> | - | +| `description?` | `string` | Package description | +| `devDependencies?` | `Record`<`string`, `string`\> | - | +| `exports?` | `null` \| `Exports` | Subpath exports to define entry points of the package. [Read more.](https://nodejs.org/api/packages.html#subpath-exports) | +| `homepage?` | `string` | - | +| `main?` | `string` | - | +| `name` | `string` | Package name | +| `peerDependencies?` | `Record`<`string`, `string`\> | - | +| `private?` | `boolean` | - | +| `tspMain?` | `string` | - | +| `type?` | `"module"` \| `"commonjs"` | - | +| `version?` | `string` | Package version | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ProjectedProgram.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ProjectedProgram.md index 7f1c831f5c..6048045bd6 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ProjectedProgram.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ProjectedProgram.md @@ -19,8 +19,8 @@ title: "[I] ProjectedProgram" | `jsSourceFiles` | `public` | `Map`<`string`, [`JsSourceFileNode`](JsSourceFileNode.md)\> | - | [`Program`](Program.md).`jsSourceFiles` | | `literalTypes` | `public` | `Map`<`string` \| `number` \| `boolean`, [`LiteralType`](../type-aliases/LiteralType.md)\> | - | [`Program`](Program.md).`literalTypes` | | `mainFile?` | `public` | [`TypeSpecScriptNode`](TypeSpecScriptNode.md) | - | [`Program`](Program.md).`mainFile` | -| `projectRoot` | `readonly` | `string` | Project root. If a tsconfig was found/specified this is the directory for the tsconfig.json. Otherwise directory where the entrypoint is located. | [`Program`](Program.md).`projectRoot` | | `projector` | `public` | [`Projector`](Projector.md) | - | - | +| `projectRoot` | `readonly` | `string` | Project root. If a tsconfig was found/specified this is the directory for the tsconfig.json. Otherwise directory where the entrypoint is located. | [`Program`](Program.md).`projectRoot` | | `sourceFiles` | `public` | `Map`<`string`, [`TypeSpecScriptNode`](TypeSpecScriptNode.md)\> | All source files in the program, keyed by their file path. | [`Program`](Program.md).`sourceFiles` | | `stateMaps` | `public` | `Map`<`symbol`, `StateMap`\> | - | [`Program`](Program.md).`stateMaps` | | `stateSets` | `public` | `Map`<`symbol`, `StateSet`\> | - | [`Program`](Program.md).`stateSets` | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ProjectionArithmeticExpressionNode.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ProjectionArithmeticExpressionNode.md index 84f8e6cf20..0879c5ba6d 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ProjectionArithmeticExpressionNode.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ProjectionArithmeticExpressionNode.md @@ -17,7 +17,7 @@ title: "[I] ProjectionArithmeticExpressionNode" | `flags` | `readonly` | [`NodeFlags`](../enumerations/NodeFlags.md) | - | - | [`BaseNode`](BaseNode.md).`flags` | | `kind` | `readonly` | `ProjectionArithmeticExpression` | - | [`BaseNode`](BaseNode.md).`kind` | - | | `left` | `readonly` | [`ProjectionExpression`](../type-aliases/ProjectionExpression.md) | - | - | - | -| `op` | `readonly` | `"-"` \| `"/"` \| `"+"` \| `"*"` | - | - | - | +| `op` | `readonly` | `"/"` \| `"*"` \| `"-"` \| `"+"` | - | - | - | | `parent?` | `readonly` | [`Node`](../type-aliases/Node.md) | - | - | [`BaseNode`](BaseNode.md).`parent` | | `pos` | `readonly` | `number` | The starting position of the ranger measured in UTF-16 code units from the start of the full string. Inclusive. | - | [`BaseNode`](BaseNode.md).`pos` | | `right` | `readonly` | [`ProjectionExpression`](../type-aliases/ProjectionExpression.md) | - | - | - | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ResolveModuleOptions.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ResolveModuleOptions.md index 39592094d3..88ae68b4fc 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ResolveModuleOptions.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ResolveModuleOptions.md @@ -5,8 +5,10 @@ title: "[I] ResolveModuleOptions" --- ## Properties -| Property | Type | Description | -| ------ | ------ | ------ | -| `baseDir` | `string` | - | -| `directoryIndexFiles?` | `string`[] | When resolution reach a directory without package.json look for those files to load in order. **Default** `["index.mjs", "index.js"]` | -| `resolveMain?` | (`pkg`: `any`) => `string` | When resolution reach package.json returns the path to the file relative to it. **Default** `pkg.main` | +| Property | Modifier | Type | Description | +| ------ | ------ | ------ | ------ | +| `baseDir` | `public` | `string` | - | +| `conditions?` | `readonly` | `string`[] | List of conditions to match in package exports | +| `directoryIndexFiles?` | `public` | `string`[] | When resolution reach a directory without package.json look for those files to load in order. **Default** `["index.mjs", "index.js"]` | +| `fallbackOnMissingCondition?` | `readonly` | `boolean` | If exports is defined ignore if the none of the given condition is found and fallback to using main field resolution. By default it will throw an error. | +| `resolveMain?` | `public` | (`pkg`: `any`) => `string` | When resolution reach package.json returns the path to the file relative to it. **Default** `pkg.main` | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ResolvedModule.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ResolvedModule.md index a8c9fb0a70..117a4e4868 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ResolvedModule.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/ResolvedModule.md @@ -8,6 +8,6 @@ title: "[I] ResolvedModule" | Property | Type | Description | | ------ | ------ | ------ | | `mainFile` | `string` | Resolved main file for the module. | -| `manifest` | [`NodePackage`](NodePackage.md) | Value of package.json. | +| `manifest` | [`PackageJson`](PackageJson.md) | Value of package.json. | | `path` | `string` | Root of the package. (Same level as package.json) | | `type` | `"module"` | - | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/SourceModel.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/SourceModel.md index 7a88fb1409..69576b31b8 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/SourceModel.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/interfaces/SourceModel.md @@ -8,4 +8,4 @@ title: "[I] SourceModel" | Property | Modifier | Type | Description | | ------ | ------ | ------ | ------ | | `model` | `readonly` | [`Model`](Model.md) | Source model | -| `usage` | `readonly` | `"is"` \| `"spread"` \| `"intersection"` | How was this model used. - is: `model A is B` - spread: `model A {...B}` - intersection: `alias A = B & C` | +| `usage` | `readonly` | `"is"` \| `"intersection"` \| `"spread"` | How was this model used. - is: `model A is B` - spread: `model A {...B}` - intersection: `alias A = B & C` | diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/DiagnosticReportWithoutTarget.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/DiagnosticReportWithoutTarget.md index 39c45e7abc..b4128299ab 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/DiagnosticReportWithoutTarget.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/DiagnosticReportWithoutTarget.md @@ -12,8 +12,8 @@ type DiagnosticReportWithoutTarget: object & DiagnosticFormat; | Name | Type | | ------ | ------ | | `code` | `C` | -| `codefixes` | readonly [`CodeFix`](../interfaces/CodeFix.md)[] | -| `messageId` | `M` | +| `codefixes`? | readonly [`CodeFix`](../interfaces/CodeFix.md)[] | +| `messageId`? | `M` | ## Type Parameters diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/LinterRuleDiagnosticReportWithoutTarget.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/LinterRuleDiagnosticReportWithoutTarget.md index 378d178aa2..1daeea2062 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/LinterRuleDiagnosticReportWithoutTarget.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/LinterRuleDiagnosticReportWithoutTarget.md @@ -11,8 +11,8 @@ type LinterRuleDiagnosticReportWithoutTarget: object & LinterRuleDiagnosti | Name | Type | | ------ | ------ | -| `codefixes` | [`CodeFix`](../interfaces/CodeFix.md)[] | -| `messageId` | `M` | +| `codefixes`? | [`CodeFix`](../interfaces/CodeFix.md)[] | +| `messageId`? | `M` | ## Type Parameters diff --git a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/SemanticNodeListener.md b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/SemanticNodeListener.md index 89b52ea9d0..b634487195 100644 --- a/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/SemanticNodeListener.md +++ b/packages/website/versioned_docs/version-latest/standard-library/reference/js-api/type-aliases/SemanticNodeListener.md @@ -11,4 +11,4 @@ type SemanticNodeListener: object & TypeListeners; | Name | Type | | ------ | ------ | -| `root` | (`context`) => `void` \| `undefined` | +| `root`? | (`context`) => `void` \| `undefined` | diff --git a/packages/website/versioned_sidebars/version-latest-sidebars.json b/packages/website/versioned_sidebars/version-latest-sidebars.json index 9937dfdba8..3996dfd809 100644 --- a/packages/website/versioned_sidebars/version-latest-sidebars.json +++ b/packages/website/versioned_sidebars/version-latest-sidebars.json @@ -87,6 +87,16 @@ "items": [ "standard-library/built-in-decorators", "standard-library/built-in-data-types", + { + "type": "category", + "label": "Diagnostics", + "items": [ + { + "type": "autogenerated", + "dirName": "standard-library/diags" + } + ] + }, { "type": "autogenerated", "dirName": "standard-library/reference" @@ -100,6 +110,20 @@ "type": "category", "label": "📚 Libraries", "items": [ + { + "type": "category", + "label": "Events", + "link": { + "type": "doc", + "id": "libraries/events/reference/index" + }, + "items": [ + { + "type": "autogenerated", + "dirName": "libraries/events/reference" + } + ] + }, { "type": "category", "label": "Http", @@ -161,6 +185,34 @@ } ] }, + { + "type": "category", + "label": "Server-Sent Events", + "link": { + "type": "doc", + "id": "libraries/sse/reference/index" + }, + "items": [ + { + "type": "autogenerated", + "dirName": "libraries/sse/reference" + } + ] + }, + { + "type": "category", + "label": "Streams", + "link": { + "type": "doc", + "id": "libraries/streams/reference/index" + }, + "items": [ + { + "type": "autogenerated", + "dirName": "libraries/streams/reference" + } + ] + }, { "type": "category", "label": "Versioning", diff --git a/packages/xml/CHANGELOG.md b/packages/xml/CHANGELOG.md index 2f0ed0f280..449e9c07c9 100644 --- a/packages/xml/CHANGELOG.md +++ b/packages/xml/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog - @typespec/xml +## 0.61.0 + +### Bump dependencies + +- [#4424](https://github.com/microsoft/typespec/pull/4424) Bump dependencies + + ## 0.60.0 ### Features diff --git a/packages/xml/package.json b/packages/xml/package.json index 36467adab9..f8fa0fc2df 100644 --- a/packages/xml/package.json +++ b/packages/xml/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/xml", - "version": "0.60.0", + "version": "0.61.0", "author": "Microsoft Corporation", "description": "TypeSpec library providing xml bindings", "homepage": "https://typespec.io", From 9121ed41eb1ac7cc0d627b46a0e6aaf5958931de Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 9 Oct 2024 15:44:06 -0700 Subject: [PATCH 13/13] [@typespec/spec-*] Apply changes from CADL to Typespec Repository (#4637) 1. As part of cadl-ranch migration, several packages have been migrated from cadl-ranch repository to typespec repository. Once the split is complete during the development, there were some changes that were pushed in cadl-ranch repository. Those changes must be shifted back to typespec repository. 2. Also, few changes are required in the packages to handle the azure specific specs (These changes are added as part of the PR: https://github.com/Azure/cadl-ranch/pull/741). 3. In addition, I have created a new package called `@azure-tools/azure-http-specs` has been created in the `typespec-azure` repository. This package has only the azure specific specs. I have tested the changes including the `pnpm test:e2e`. All validations are successful. The changes in this PR will be required for creating the PR for `@azure-tools/azure-http-specs` (which I will create once this PR is merged). Please review and approve this PR. Thanks --- .../specs/encode/duration/mockapi.ts | 7 ------- packages/spec-core/src/actions/helper.ts | 10 ++++++++++ packages/spec-core/src/actions/server-test.ts | 7 ++++--- packages/spec-core/src/scenarios-resolver.ts | 18 +++++++++++++++--- .../generated-defs/TypeSpec.SpecLib.ts | 4 ++-- packages/spec-lib/lib/lib.tsp | 2 +- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/packages/http-specs/specs/encode/duration/mockapi.ts b/packages/http-specs/specs/encode/duration/mockapi.ts index aa161421dc..6008f9ad0a 100644 --- a/packages/http-specs/specs/encode/duration/mockapi.ts +++ b/packages/http-specs/specs/encode/duration/mockapi.ts @@ -36,13 +36,6 @@ Scenarios.Encode_Duration_Property_default = createBodyServerTests( }, "P40D", ); -Scenarios.Encode_Duration_Property_default = createBodyServerTests( - "/encode/duration/property/float-seconds", - { - value: 35.625, - }, - 35.625, -); Scenarios.Encode_Duration_Property_floatSeconds = createBodyServerTests( "/encode/duration/property/float-seconds", { diff --git a/packages/spec-core/src/actions/helper.ts b/packages/spec-core/src/actions/helper.ts index 7882cd5b54..3948b75499 100644 --- a/packages/spec-core/src/actions/helper.ts +++ b/packages/spec-core/src/actions/helper.ts @@ -35,10 +35,20 @@ function checkAndAddFormDataIfRequired(request: ServiceRequest) { } } +function checkAndUpdateEndpoint(request: ServiceRequest) { + if (request.options?.config?.params) { + for (const key in request.options.config.params) { + request.endPoint = request.endPoint.replace(`:${key}`, request.options.config.params[key]); + } + } + request.endPoint = request.endPoint.replace(/\[:\]/g, ":"); +} + export async function makeServiceCall( serviceCallType: HttpMethod, request: ServiceRequest, ): Promise> { + checkAndUpdateEndpoint(request); checkAndAddFormDataIfRequired(request); if (serviceCallType === "put") { return await makePutCall(request); diff --git a/packages/spec-core/src/actions/server-test.ts b/packages/spec-core/src/actions/server-test.ts index b0409470bd..c22e6b83b4 100644 --- a/packages/spec-core/src/actions/server-test.ts +++ b/packages/spec-core/src/actions/server-test.ts @@ -53,7 +53,6 @@ class ServerTestsGenerator { } public async executeScenario() { - // for (const mockMethod of this.mockMethods) { logger.info(`Executing ${this.name} endpoint - Method: ${this.mockApiDefinition.method}`); const response = await makeServiceCall(this.mockApiDefinition.method, { @@ -127,7 +126,10 @@ class ServerTestsGenerator { } if (this.mockApiDefinition.response.headers) { for (const key in this.mockApiDefinition.response.headers) { - if (this.mockApiDefinition.response.headers[key] !== response.headers[key]) { + if ( + this.mockApiDefinition.response.headers[key] !== + response.headers[key].replace(this.serverBasePath, "") + ) { logger.error(`Response headers mismatch for ${this.name} endpoint`); logger.error( `Expected: ${this.mockApiDefinition.response.headers[key]} - Actual: ${response.headers[key]}`, @@ -136,7 +138,6 @@ class ServerTestsGenerator { } } } - // } } } diff --git a/packages/spec-core/src/scenarios-resolver.ts b/packages/spec-core/src/scenarios-resolver.ts index c5a49fe006..32f20211f2 100644 --- a/packages/spec-core/src/scenarios-resolver.ts +++ b/packages/spec-core/src/scenarios-resolver.ts @@ -41,7 +41,7 @@ export async function findScenarioSpecFiles(scenariosPath: string): Promise = {}; + const duplicateTracker: Record = {}; for (const file of files) { for (const [key, scenario] of Object.entries(file.scenarios)) { - if (key in result) { - logger.warn(`Scenario ${key} is being defined twice.`); + if (duplicateTracker[key]) { + duplicateTracker[key].push(file.path); + } else { + duplicateTracker[key] = [file.path]; } + result[key] = scenario; } } + + for (const [key, paths] of Object.entries(duplicateTracker)) { + if (paths.length >= 2) { + logger.warn( + `Scenario ${key} is being defined multiple times in mockapis:\n${paths.map((x) => ` ${x}`).join("\n")}`, + ); + } + } return result; } diff --git a/packages/spec-lib/generated-defs/TypeSpec.SpecLib.ts b/packages/spec-lib/generated-defs/TypeSpec.SpecLib.ts index bed4b661d0..97dc5a2009 100644 --- a/packages/spec-lib/generated-defs/TypeSpec.SpecLib.ts +++ b/packages/spec-lib/generated-defs/TypeSpec.SpecLib.ts @@ -1,10 +1,10 @@ import type { DecoratorContext, - EnumValue, Interface, Model, Namespace, Operation, + Type, } from "@typespec/compiler"; /** @@ -14,7 +14,7 @@ export type ScenarioServiceDecorator = ( context: DecoratorContext, target: Namespace, route: string, - options?: { readonly versioned?: EnumValue }, + options?: Type, ) => void; /** diff --git a/packages/spec-lib/lib/lib.tsp b/packages/spec-lib/lib/lib.tsp index d01b93432a..7c07d9df91 100644 --- a/packages/spec-lib/lib/lib.tsp +++ b/packages/spec-lib/lib/lib.tsp @@ -17,7 +17,7 @@ alias ScenarioServiceOptions = { extern dec scenarioService( target: Namespace, route: valueof string, - options?: valueof ScenarioServiceOptions + options?: ScenarioServiceOptions ); /**