Skip to content

Commit 657d641

Browse files
Remove logic that moves models out of models directory once migration is complete (#54132)
* Initial plan * Remove logic that moves models out of models directory This removes the migration-specific logic that was added to the NamespaceVisitor to move model files out of the Models directory when model-namespace was set to false. This logic was originally added to make GitHub diffs easier to review during the migration to the new generator. Since diffs are now easy to understand, this logic is no longer needed. Fixes #50286 Co-authored-by: JoshLove-msft <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JoshLove-msft <[email protected]>
1 parent 3a9791c commit 657d641

File tree

689 files changed

+0
-49
lines changed

Some content is hidden

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

689 files changed

+0
-49
lines changed

eng/packages/http-client-csharp/generator/Azure.Generator/src/Visitors/NamespaceVisitor.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
using System.IO;
54
using Azure.Generator.Extensions;
65
using Microsoft.TypeSpec.Generator;
76
using Microsoft.TypeSpec.Generator.ClientModel;
@@ -72,20 +71,6 @@ private static void UpdateModelsNamespace(TypeProvider type)
7271
$"{CodeModelGenerator.Instance.TypeFactory.PrimaryNamespace}.Models"));
7372
}
7473
}
75-
else
76-
{
77-
// TODO - remove this once all libraries have been migrated to the new generator. Leaving this
78-
// here to make diffs easier to review while migrating. Calculate the fileName as it won't always match the Name
79-
// property, e.g. for serialization providers.
80-
// https://github.com/Azure/azure-sdk-for-net/issues/50286
81-
var separator = Path.DirectorySeparatorChar;
82-
if (type.RelativeFilePath.Contains($"Generated{separator}Models{separator}"))
83-
{
84-
var fileName = Path.GetRelativePath(Path.Combine("src", "Generated", "Models"),
85-
type.RelativeFilePath);
86-
type.Update(relativeFilePath: Path.Combine("src", "Generated", fileName));
87-
}
88-
}
8974
}
9075
}
9176
}

eng/packages/http-client-csharp/generator/Azure.Generator/test/Visitors/NamespaceVisitorTests.cs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
using System;
5-
using System.IO;
64
using Microsoft.TypeSpec.Generator.Input;
75
using Microsoft.TypeSpec.Generator.Providers;
86
using NUnit.Framework;
@@ -41,38 +39,6 @@ public void DoesNotUseModelsNamespaceIfConfigSetToFalse()
4139
Assert.AreEqual("Samples", updatedModel!.Type.Namespace);
4240
}
4341

44-
[Test]
45-
public void MovesModelsOutOfModelsDirectory()
46-
{
47-
MockHelpers.LoadMockGenerator(configurationJson: "{ \"package-name\": \"TestLibrary\", \"model-namespace\": false }");
48-
var visitor = new TestNamespaceVisitor();
49-
var inputType = InputFactory.Model("TestModel", "Samples");
50-
var model = new ModelProvider(inputType);
51-
var updatedModel = visitor.InvokePreVisitModel(inputType, model);
52-
53-
Assert.IsNotNull(updatedModel);
54-
Assert.AreEqual(
55-
$"src{Path.DirectorySeparatorChar}Generated{Path.DirectorySeparatorChar}{updatedModel!.Name}.cs",
56-
updatedModel.RelativeFilePath);
57-
}
58-
59-
[Test]
60-
public void DoesNotMoveModelIfNotInModelsDirectory()
61-
{
62-
MockHelpers.LoadMockGenerator(configurationJson: "{ \"package-name\": \"TestLibrary\", \"model-namespace\": false }");
63-
var visitor = new TestNamespaceVisitor();
64-
var inputType = InputFactory.Model("TestModels", "Samples");
65-
var model = new ModelProvider(inputType);
66-
67-
model.Update(relativeFilePath: $"src{Path.DirectorySeparatorChar}Generated{Path.DirectorySeparatorChar}{model.Name}.cs");
68-
var updatedModel = visitor.InvokePreVisitModel(inputType, model);
69-
70-
Assert.IsNotNull(updatedModel);
71-
Assert.AreEqual(
72-
$"src{Path.DirectorySeparatorChar}Generated{Path.DirectorySeparatorChar}{updatedModel!.Name}.cs",
73-
updatedModel.RelativeFilePath);
74-
}
75-
7642
[Test]
7743
public void DoesNotChangeNamespaceOfFormatEnum()
7844
{

0 commit comments

Comments
 (0)