This goes into the following assembly:
[TestFixture] public class SO17245073 { [Test] public void Exec() { var model = TypeModel.Create(); Assert.IsFalse(model[typeof(A)].EnumPassthru, "A"); Assert.IsTrue(model[typeof(B)].EnumPassthru, "B"); Assert.IsFalse(model[typeof(C)].EnumPassthru, "C"); Assert.IsTrue(model[typeof(D)].EnumPassthru, "D"); Assert.IsTrue(model[typeof(E)].EnumPassthru, "E"); Assert.IsTrue(model[typeof(F)].EnumPassthru, "F"); Assert.IsFalse(model[typeof(G)].EnumPassthru, "G"); Assert.IsFalse(model[typeof(H)].EnumPassthru, "H"); }
From your sample code here:
if (type.IsEnum && type.GetCustomAttribute<ProtoContractAttribute>() != null)
this looks like all you have to do, since you already have [ProtoContract] , do this [ProtoContract(EnumPassthru = true)] in your enum ads.
source share