Skip to content

Commit 513ae5f

Browse files
authored
let context writer has the same namespace and name for multiple batch run (#5391)
1 parent d07a7c5 commit 513ae5f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/AutoRest.CSharp/Common/Generation/Writers/ModelReaderWriterContextWriter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace AutoRest.CSharp.Common.Generation.Writers
1818
{
1919
internal class ModelReaderWriterContextWriter
2020
{
21+
private static string Namespace = Configuration.Namespace;
22+
2123
public void Write(CodeWriter writer, IEnumerable<TypeProvider>? models = null)
2224
{
2325
IEnumerable<CSharpType>? buildableTypes = null;
@@ -28,7 +30,7 @@ public void Write(CodeWriter writer, IEnumerable<TypeProvider>? models = null)
2830
buildableTypes = CollectBuildableTypes(models);
2931
}
3032

31-
using (writer.Namespace($"{Configuration.Namespace}"))
33+
using (writer.Namespace($"{Namespace}"))
3234
{
3335
writer.Line($"/// <summary>");
3436
writer.Line($"/// Context class which will be filled in by the System.ClientModel.SourceGeneration.");
@@ -169,7 +171,7 @@ private bool ImplementsIPersistableModel(CSharpType type, Dictionary<CSharpType,
169171
return type.FrameworkType.GetInterfaces().Any(i => i.Name == "IPersistableModel`1" || i.Name == "IJsonModel`1");
170172
}
171173

172-
public static string Name => $"{Configuration.Namespace.RemovePeriods()}Context";
174+
public static string Name = $"{Configuration.Namespace.RemovePeriods()}Context";
173175

174176
private class CSharpTypeNameComparer : IEqualityComparer<CSharpType>
175177
{

0 commit comments

Comments
 (0)