Skip to content

Commit 2de7930

Browse files
Generate CodeGen customization attributes in fixed namespace (#9122)
- [x] Understand the issue: CodeGen customization attributes should be generated in a fixed namespace to avoid API compatibility failures - [x] Identify the suggested namespace from Azure SDK issue #54144: `Microsoft.TypeSpec.Generator.Customizations` - [x] Add `CustomizationAttributeNamespace` constant to `CodeModelGenerator` class (changed to `internal` per review feedback) - [x] Override `BuildNamespace()` in CodeGen attribute definition classes to return the fixed namespace - [x] Update test data files to use the new namespace - [x] Update expected test strings in `ClientCustomizationTests` - [x] Update custom code files in Sample-TypeSpec to import the new namespace - [x] Update generated attribute files in Sample-TypeSpec to use the new namespace - [x] Run tests to validate changes (all pass) - [x] Request code review (passed with no comments) - [x] Address review feedback: Changed `CustomizationAttributeNamespace` from `public` to `internal` ## Security Summary No security vulnerabilities were introduced. The changes only modify namespace declarations and add using directives - no new code paths, no external inputs, and no changes to security-sensitive logic. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Generate CodeGen customization attributes in fixed namespace</issue_title> > <issue_description>See Azure/azure-sdk-for-net#54144 for more context.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes #9121 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
1 parent ea81836 commit 2de7930

File tree

77 files changed

+94
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+94
-9
lines changed

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/CanRemoveCachingField/CanRemoveCachingField.cs

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

22
using System;
33
using SampleTypeSpec;
4+
using Microsoft.TypeSpec.Generator.Customizations;
45

56
namespace Sample
67
{

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientProviders/TestData/ClientProviderCustomizationTests/CanRenameSubClient/CanRenameSubClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using SampleTypeSpec;
2+
using Microsoft.TypeSpec.Generator.Customizations;
23

34
namespace Sample
45
{

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/Definitions/TestData/Classifier2xxAnd4xxDefinitionTests/TestGetTypeCustomNamespace/TestGetTypeCustomNamespace.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.ClientModel.Primitives;
55
using System.Threading.Tasks;
66
using SampleTypeSpec;
7+
using Microsoft.TypeSpec.Generator.Customizations;
78

89
namespace Sample.Custom;
910

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/EnumProvider/TestData/SerializationCustomizationTests/CanChangeEnumMemberName/MockInputModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#nullable disable
22

33
using SampleTypeSpec;
4+
using Microsoft.TypeSpec.Generator.Customizations;
45

56
namespace Sample.Models
67
{

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/DynamicModelSerializationTests/PropagateCustomizedDynamicListProperty/DynamicModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using SampleTypeSpec;
22
using System.Collections.Generic;
3+
using Microsoft.TypeSpec.Generator.Customizations;
34

45
namespace Sample.Models
56
{

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/DynamicModelSerializationTests/PropagateCustomizedDynamicListPropertyMixed/DynamicModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using SampleTypeSpec;
22
using System.Collections.Generic;
3+
using Microsoft.TypeSpec.Generator.Customizations;
34

45
namespace Sample.Models
56
{

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/DynamicModelSerializationTests/PropagateCustomizedDynamicProperty/DynamicModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using SampleTypeSpec;
22

3+
using Microsoft.TypeSpec.Generator.Customizations;
4+
35
namespace Sample.Models
46
{
57
public partial class DynamicModel

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/DynamicModelSerializationTests/PropagateCustomizedDynamicPropertyMixed/DynamicModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using SampleTypeSpec;
22

3+
using Microsoft.TypeSpec.Generator.Customizations;
4+
35
namespace Sample.Models
46
{
57
public partial class DynamicModel

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/DynamicModelSerializationTests/WriteReadOnlySpanProperty/DynamicModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using SampleTypeSpec;
44
using System;
55
using System.Diagnostics.CodeAnalysis;
6+
using Microsoft.TypeSpec.Generator.Customizations;
67

78
namespace Sample.Models
89
{

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/MrwSerializationTypeDefinitions/TestData/ModelCustomizationTests/CanChangePropertyName/MockInputModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#nullable disable
22

33
using SampleTypeSpec;
4+
using Microsoft.TypeSpec.Generator.Customizations;
45

56
namespace Sample.Models
67
{

0 commit comments

Comments
 (0)