Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ public void Update(
// Reset the custom code view to reflect the new namespace
_customCodeView = new(BuildCustomCodeView(Type.Name, @namespace));
_lastContractView = new(BuildLastContractView(Type.Name, @namespace));
_declarationModifiers = BuildDeclarationModifiersInternal(); // recalculate declaration modifiers
Type.Update(@namespace: _customCodeView.Value?.Type.Namespace ?? @namespace);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,28 @@ public async Task CanCustomizeModelNameWithCustomizedNamespace()
Assert.AreEqual("NewNamespace", updatedModel.Type.Namespace);
}

[Test]
public async Task CanCustomizeAccessibilityWithCustomizedNamespace()
{
await MockHelpers.LoadMockGeneratorAsync(compilation: async () => await Helpers.GetCompilationFromDirectoryAsync());

var props = new[]
{
InputFactory.Property("prop1", InputFactory.Array(InputPrimitiveType.String))
};

var inputModel = InputFactory.Model("mockInputModel", properties: props);
var modelTypeProvider = new ModelProvider(inputModel);

var namespaceVisitor = new TestNamespaceVisitor();
var nameVisitor = new TestNameVisitor();
var updatedModel = nameVisitor.InvokeVisit(namespaceVisitor.InvokeVisit(modelTypeProvider)!);
Assert.IsNotNull(updatedModel);
Assert.AreEqual("CustomizedModel", updatedModel!.Name);
Assert.AreEqual("NewNamespace", updatedModel.Type.Namespace);
Assert.IsTrue(updatedModel.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Internal));
}

[Test]
public async Task DiscriminatorPropertyNotGeneratedIfOnCustomizedBase()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

using System;
using SampleTypeSpec;

namespace NewNamespace;

internal class MockInputModel
{
}
Loading