Skip to content

Commit 18e877c

Browse files
fix the issue that codegentype cannot change namespace of resource/resource collection (#5394)
1 parent f8285c3 commit 18e877c

File tree

12 files changed

+36
-9
lines changed

12 files changed

+36
-9
lines changed

src/AutoRest.CSharp/Mgmt/Generation/MgmtClientBaseWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected MgmtClientBaseWriter(CodeWriter writer, MgmtTypeProvider provider)
5656

5757
public virtual void Write()
5858
{
59-
using (_writer.Namespace(This.Namespace))
59+
using (_writer.Namespace(This.Declaration.Namespace))
6060
{
6161
WriteClassDeclaration();
6262
using (_writer.Scope())

src/AutoRest.CSharp/Mgmt/Output/MgmtTypeProvider.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ protected MgmtTypeProvider(string resourceName) : base(MgmtContext.Context)
6868

6969
public virtual FormattableString BranchIdVariableName => $"Id";
7070

71-
public string Namespace => DefaultNamespace;
72-
73-
public virtual string DiagnosticNamespace => Namespace;
71+
public virtual string DiagnosticNamespace => Declaration.Namespace;
7472

7573
public abstract CSharpType? BaseType { get; }
7674

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
#nullable disable
5+
6+
using Azure.Core;
7+
8+
namespace MgmtCustomizations.Pets
9+
{
10+
[CodeGenType("PetStoreCollection")]
11+
public partial class PetStoreCollection {}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
#nullable disable
5+
6+
using Azure.Core;
7+
8+
namespace MgmtCustomizations.Pets
9+
{
10+
[CodeGenType("PetStoreResource")]
11+
public partial class PetStoreResource {}
12+
}

test/TestProjects/MgmtCustomizations/src/Generated/Extensions/MgmtCustomizationsExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Azure.ResourceManager;
1414
using Azure.ResourceManager.Resources;
1515
using MgmtCustomizations.Mocking;
16+
using MgmtCustomizations.Pets;
1617

1718
namespace MgmtCustomizations
1819
{

test/TestProjects/MgmtCustomizations/src/Generated/Extensions/MockableMgmtCustomizationsArmClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
using Azure.Core;
99
using Azure.ResourceManager;
10+
using MgmtCustomizations.Pets;
1011

1112
namespace MgmtCustomizations.Mocking
1213
{

test/TestProjects/MgmtCustomizations/src/Generated/Extensions/MockableMgmtCustomizationsResourceGroupResource.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Azure;
1212
using Azure.Core;
1313
using Azure.ResourceManager;
14+
using MgmtCustomizations.Pets;
1415

1516
namespace MgmtCustomizations.Mocking
1617
{

test/TestProjects/MgmtCustomizations/src/Generated/LongRunningOperation/PetStoreOperationSource.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Azure;
1212
using Azure.Core;
1313
using Azure.ResourceManager;
14+
using MgmtCustomizations.Pets;
1415

1516
namespace MgmtCustomizations
1617
{

test/TestProjects/MgmtCustomizations/src/Generated/Models/MgmtCustomizationsContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Azure;
1010
using Azure.ResourceManager.Models;
1111
using MgmtCustomizations.Models;
12+
using MgmtCustomizations.Pets;
1213

1314
namespace MgmtCustomizations
1415
{

test/TestProjects/MgmtCustomizations/src/Generated/PetStoreCollection.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)