Skip to content

Commit

Permalink
Use EmptyPolymorphicNamespace in JsonConvertersSerializerJsonContextG…
Browse files Browse the repository at this point in the history
…enerator (#35)
  • Loading branch information
trejjam authored Nov 8, 2023
1 parent bef5911 commit 32028fe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//HintName: ProjectJsonSerializerContext.g.cs
#nullable enable

namespace ;
namespace PolymorphicGlobalNamespace;

public partial class ProjectJsonSerializerContext
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ IReadOnlyCollection<JsonConverter> converters
classAccessibility = $"{classAccessibility} sealed";
}

var targetNamespace = jsonSerializerContextClassType.ContainingNamespace.ToDisplayString(JsonPolymorphicConverterIncrementalGenerator.NamespaceFormat);
var targetNamespace = jsonSerializerContextClassType.ContainingNamespace.IsGlobalNamespace
? JsonPolymorphicConverterIncrementalGenerator.EmptyPolymorphicNamespace
: jsonSerializerContextClassType.ContainingNamespace.ToDisplayString(JsonPolymorphicConverterIncrementalGenerator.NamespaceFormat);

return Generate(
converterType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class JsonPolymorphicConverterIncrementalGenerator : IIncrementalGenerato
{
public const string Id = "AVI_JPC";

private const string EmptyPolymorphicNamespace = "PolymorphicGlobalNamespace";
public const string EmptyPolymorphicNamespace = "PolymorphicGlobalNamespace";

internal static readonly SymbolDisplayFormat NamespaceFormat = new(
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted,
Expand Down

0 comments on commit 32028fe

Please sign in to comment.