Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose public setter of namespace #5928

Merged
merged 14 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 8 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 @@ -46,7 +46,7 @@ public RestClientProvider(InputClient inputClient, ClientProvider clientProvider

protected override string BuildName() => _inputClient.Name.ToCleanName();

protected override string BuildNamespace() => ClientProvider.Namespace;
protected override string BuildNamespace() => ClientProvider.Type.Namespace;

protected override PropertyProvider[] BuildProperties()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public async Task PostProcessAsync()
var modelFactory = ModelFactoryProvider.FromInputLibrary();
var postProcessor = new PostProcessor(
[.. CodeModelPlugin.Instance.TypeFactory.UnionTypes, .. CodeModelPlugin.Instance.TypesToKeep],
modelFactoryFullName: $"{modelFactory.Namespace}.{modelFactory.Name}");
modelFactoryFullName: $"{modelFactory.Type.Namespace}.{modelFactory.Name}");
switch (Configuration.UnreferencedTypesHandling)
{
case Configuration.UnreferencedTypesHandlingOption.KeepAll:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ internal CSharpType(
_underlyingType = underlyingEnumType;
}

public string Namespace { get; private init; }
public string Namespace { get; set; }
public string Name { get; private init; }
public CSharpType? DeclaringType { get; private init; }
public bool IsValueType { get; private init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public CanonicalTypeProvider(TypeProvider generatedTypeProvider, InputType? inpu

protected override string BuildName() => _generatedTypeProvider.Name;

protected override string BuildNamespace() => _generatedTypeProvider.Namespace;
protected override string BuildNamespace() => _generatedTypeProvider.Type.Namespace;

protected override TypeSignatureModifiers BuildDeclarationModifiers() => _generatedTypeProvider.DeclarationModifiers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.TypeSpec.Generator.Providers
{
internal abstract class EnumProvider : TypeProvider
public abstract class EnumProvider : TypeProvider
{
private readonly InputEnumType _inputType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Microsoft.TypeSpec.Generator.Providers
{
internal class ModelFactoryProvider : TypeProvider
public class ModelFactoryProvider : TypeProvider
{
private const string ModelFactorySuffix = "ModelFactory";
private const string AdditionalBinaryDataParameterName = "additionalBinaryDataProperties";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ private IReadOnlyList<FieldProvider> BuildAllCustomFields()

private string? _name;

public string Namespace => _namespace ??= BuildNamespace();
private string? _namespace;

protected virtual FormattableString Description { get; } = FormattableStringHelpers.Empty;

private XmlDocProvider? _xmlDocs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void ValidateName()
[Test]
public void ValidateNamespace()
{
Assert.AreEqual(_typeProvider.Namespace, _typeProvider.CanonicalView.Namespace);
Assert.AreEqual(_typeProvider.Type.Namespace, _typeProvider.CanonicalView.Type.Namespace);
}

[Test]
Expand Down
Loading