I have tried MessagePack 3.0.134-beta on my project. So far new analyzer detections force a very strict style that requires a lot of refactoring to get it going. This might be not the best code, but on large code base refactoring is always a matter of time you can spend for this. Analyzer for 2.5.172 was fine with that code.
Questions:
Test1 - Why are we forced to start with 0 for constructor params? For me it is not always the case and I cannot change that.
Test2, Test3 - Requirement to make partial class doesn't make sense. Code gen still has to use constructor.
Test4 - Maybe analyzer should detect private member not annotated with attributes only when class is partial?
Common patterns detected:
[MessagePackObject]
public class Test1
{
[Key(1)]
//[Key("1")]// works fine with string keys
public string Name { get; }
[SerializationConstructor]
public Test1(string name) => Name = name;
}
[MessagePackObject]
public class Test2
{
private readonly string _name;
[Key(0)]
public string Name => _name;
[SerializationConstructor]
public Test2(string name) => _name = name;
}
// another way Test2 can implemented
[MessagePackObject]
public class Test3
{
[Key(0)]
public string Name { get; private set; }
[SerializationConstructor]
public Test3(string name) => Name = name;
}
[MessagePackObject]
public class Test4
{
private int? _cachedValue;// not serialized by design
[Key(0)]
public string Name { get; set; }
}
I have tried MessagePack
3.0.134-betaon my project. So far new analyzer detections force a very strict style that requires a lot of refactoring to get it going. This might be not the best code, but on large code base refactoring is always a matter of time you can spend for this. Analyzer for2.5.172was fine with that code.Questions:
Test1- Why are we forced to start with0for constructor params? For me it is not always the case and I cannot change that.Test2,Test3- Requirement to makepartialclass doesn't make sense. Code gen still has to use constructor.Test4- Maybe analyzer should detect private member not annotated with attributes only when class ispartial?Common patterns detected: