The documentaion states:
_You can use [DataContract] instead of [MessagePackObject]. If type is marked DataContract, you can use [DataMember] instead of [Key] and [IgnoreDataMember] instead of [IgnoreMember]._
But the analyzer considers types with [DataContract] not compliant. In fact they work well with MessagePack (1.9 and 2.1 as well).
[DataContract]
public struct Party {
[DataMember(Order = 0)]
public int Type;
[DataMember(Order = 1)]
public string Number;
}
[MessagePackObject]
public class CallItemPoco
{
[Key(0)]
public string Id { get; set; }
[Key(1)]
public Party Remote { get; set; } // THIS IS MARKED WITH ERROR
}
No error should be generated.
MsgPack003 Use MessagePackObjectAttribute
An exception was caught by VS, difficult to say, whether it is related to this bug:
System.ArgumentNullException : Value cannot be null.
Parameter name: document
at async Microsoft.CodeAnalysis.Editing.DocumentEditor.CreateAsync()
at async MessagePackAnalyzer.MessagePackCodeFixProvider.AddKeyAttributeAsync()
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync()
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync()
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync()
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync()
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.<>c__DisplayClass11_0.b__0( )
at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsyncT
DataContract is used in various way.
Considering that it is not used only for MessagePack, it is excluded from detection.
Are you saying this is by design, @neuecc? I'm hoping you won't object to (my) fixing this.
I don't see why we would want to produce an error in this case since we do in fact support DataContract attributes. And the analyzer is clearly throwing an exception, making a nasty looking infobar in VS. So we clearly have something to fix here.
error is bug, should fix.
What I'm saying is whether to target DataContract to the Analyzer.
Current design is only work for MessagePackObjectAttribute.
https://github.com/neuecc/MessagePack-CSharp/blob/master/src/MessagePackAnalyzer/MessagePackAnalyzer.cs#L89-L91
Since you have this (very needed feature!) of respecting DataContract attribute, the analyzer should tolerate it as well. For me this means that I:
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This is probably low-priority issue... no idea how much work it requires.
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.