Fix handling of name collisions in type hierarchies by AArnott · Pull Request #2006 · MessagePack-CSharp/MessagePack-CSharp · GitHub
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
56 changes: 56 additions & 0 deletions doc/analyzers/MsgPack018.md
1 change: 1 addition & 0 deletions doc/analyzers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ ID | Title
[MsgPack015](MsgPack015.md) | MessagePackObjectAttribute.AllowPrivate should be set
[MsgPack016](MsgPack016.md) | KeyAttribute-derived attributes are not supported by AOT formatters
[MsgPack017](MsgPack017.md) | Property with init accessor and initializer
[MsgPack018](MsgPack018.md) | Unique names required in force map mode

[1]: https://nuget.org/packages/MessagePackAnalyzer
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ MsgPack014 | Usage | Warning | Formatters of reference types should implement `I
MsgPack015 | Usage | Warning | MessagePackObjectAttribute.AllowPrivate should be set
MsgPack016 | Usage | Error | KeyAttribute-derived attributes are not supported by AOT formatters
MsgPack017 | Usage | Warning | Property with init accessor and initializer
MsgPack018 | Usage | Error | Unique names required in force map mode
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class MsgPack00xMessagePackAnalyzer : DiagnosticAnalyzer
public const string MessagePackObjectAllowPrivateId = "MsgPack015";
public const string AOTDerivedKeyId = "MsgPack016";
public const string AOTInitPropertyId = "MsgPack017";
public const string CollidingMemberNamesInForceMapModeId = "MsgPack018";

internal const string Category = "Usage";

Expand Down Expand Up @@ -301,6 +302,15 @@ public class MsgPack00xMessagePackAnalyzer : DiagnosticAnalyzer
isEnabledByDefault: true,
helpLinkUri: AnalyzerUtilities.GetHelpLink(MessagePackObjectAllowPrivateId));

public static readonly DiagnosticDescriptor CollidingMemberNamesInForceMapMode = new(
id: CollidingMemberNamesInForceMapModeId,
title: "Unique names required in force map mode",
category: Category,
messageFormat: "All serialized member names must be unique in force map mode, but this member redeclares a member with the same name as one found on a base type",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true,
helpLinkUri: AnalyzerUtilities.GetHelpLink(CollidingMemberNamesInForceMapModeId));

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(
TypeMustBeMessagePackObject,
MessageFormatterMustBeMessagePackFormatter,
Expand All @@ -327,7 +337,8 @@ public class MsgPack00xMessagePackAnalyzer : DiagnosticAnalyzer
PartialTypeRequired,
InaccessibleDataType,
NullableReferenceTypeFormatter,
MessagePackObjectAllowPrivateRequired);
MessagePackObjectAllowPrivateRequired,
CollidingMemberNamesInForceMapMode);

public override void Initialize(AnalysisContext context)
{
Expand Down
Loading