Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into response-abstraction
  • Loading branch information
live1206 committed Sep 26, 2024
commit 8696e52f8467b3592bab37d6bde9e04586e8044f
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Generator.CSharp.ClientModel", "..\..\..\..\..\..\work\typespec\packages\http-client-csharp\generator\Microsoft.Generator.CSharp.ClientModel\src\Microsoft.Generator.CSharp.ClientModel.csproj", "{9B280BB0-0A82-4635-A8F7-A44FDF7EF316}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicTypeSpec", "TestProjects\Local\Basic-TypeSpec\src\BasicTypeSpec.csproj", "{F8386530-1166-438C-99DC-AE855036A37C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Generator.Tests", "Azure.Generator\test\Azure.Generator.Tests.csproj", "{A05E6873-DD18-44B2-88A8-DEE3AA103EC4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -27,6 +28,10 @@ Global
{F8386530-1166-438C-99DC-AE855036A37C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F8386530-1166-438C-99DC-AE855036A37C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F8386530-1166-438C-99DC-AE855036A37C}.Release|Any CPU.Build.0 = Release|Any CPU
{A05E6873-DD18-44B2-88A8-DEE3AA103EC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A05E6873-DD18-44B2-88A8-DEE3AA103EC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A05E6873-DD18-44B2-88A8-DEE3AA103EC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A05E6873-DD18-44B2-88A8-DEE3AA103EC4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<PackageId>Azure.Generator</PackageId>
<Version>1.0.0-beta.1</Version>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<NoWarn>CS8002</NoWarn>
<LangVersion>latest</LangVersion>
<NoWarn>CS8002</NoWarn>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Azure.Generator.Primitives;
using Azure.Generator.Providers;
using Microsoft.Generator.CSharp.ClientModel;
using Microsoft.Generator.CSharp.ClientModel.Providers;
using Microsoft.Generator.CSharp.Expressions;
using Microsoft.Generator.CSharp.Input;
using Microsoft.Generator.CSharp.Primitives;

namespace Azure.Generator
Expand All @@ -29,5 +31,34 @@ public class AzureTypeFactory : ScmTypeFactory

/// <inheritdoc/>
public override HttpResponseApi CreateHttpResponse(ValueExpression original) => new AzureResponseProvider(original.As<Response>());

protected override CSharpType? CreateCSharpTypeCore(InputType inputType)
{
if (inputType is InputPrimitiveType inputPrimitiveType)
{
var result = CreateKnownPrimitiveType(inputPrimitiveType);
if (result != null)
{
return result;
}
}
return base.CreateCSharpTypeCore(inputType);
}

private CSharpType? CreateKnownPrimitiveType(InputPrimitiveType inputType)
{
InputPrimitiveType? primitiveType = inputType;
while (primitiveType != null)
{
if (KnownAzureTypes.PrimitiveTypes.TryGetValue(primitiveType.CrossLanguageDefinitionId, out var knownType))
{
return knownType;
}

primitiveType = primitiveType.BaseType;
}

return null;
}
}
}
You are viewing a condensed version of this merge commit. You can view the full changes here.