Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization fails is some cases when there are multiple type aliases #68

Closed
kylemc opened this issue Jul 11, 2015 · 3 comments
Closed

Comments

@kylemc
Copy link

kylemc commented Jul 11, 2015

[Update]
I got codegen and samples working with two --using="type-alias=generated-code-type" statements in the options. Unfortunately, serialization still fails with the exception below.

I'm trying to author an IDL with multiple aliases. The IDL parses fine, but the compiler doesn't seem to account for more than one kvp in the --using parameter.

Expected:
--using="datetime=System.DateTime;guid=System.Guid" works

[global::Bond.Id(2), global::Bond.Type(typeof(ulong)), global::Bond.Required]
public System.DateTime timestampUtc { get; set; }

Actual:
--using="datetime=System.DateTime;guid=System.Guid"

results in generated code like the following:

[global::Bond.Id(2), global::Bond.Type(typeof(ulong)), global::Bond.Required]
public System.DateTime,guid=System.Guid timestampUtc { get; set; }
@kylemc
Copy link
Author

kylemc commented Jul 13, 2015

One of the workarounds I tried was multiple --using options, but it resulted in the following exception which pointed to a bad join on aliased types and made me think that only the single option was being read.

System.TypeInitializationException was unhandled by user code
HResult=-2146233036
Message=The type initializer for 'Cache2' threw an exception. Source=Bond TypeName=Cache2
StackTrace:
at Bond.Serialize.To[W,T](W writer, T obj)
at Bond.Bonded1.Bond.IBonded.Serialize[W](W writer) at lambda_method(Closure , Object , CompactBinaryWriter1 )
at Bond.Serializer1.Serialize(Object obj, W writer) at Bond.Serialize.To[W,T](W writer, T obj) InnerException: System.ArgumentNullException HResult=-2147467261 Message=Value cannot be null. Parameter name: field Source=System.Core ParamName=field StackTrace: at System.Linq.Expressions.Expression.Field(Expression expression, FieldInfo field) at Bond.Expressions.DataExpression.PropertyOrField(Expression expression, String name) at Bond.Expressions.ObjectParser.Field(ITransform transform, Expression structVar, UInt16 id, ISchemaField schemaField, IField field) at Bond.Expressions.ObjectParser.<>c__DisplayClassc.<Apply>b__7(<>f__AnonymousType02 <>h__TransparentIdentifier0, IField knownField)
at System.Linq.Enumerable.d__43.MoveNext() at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable1 collection) at System.Collections.Generic.List1.AddRange(IEnumerable1 collection) at Bond.Expressions.ObjectParser.Apply(ITransform transform) at Bond.Expressions.SerializerTransform2.Struct(IParser parser, RuntimeSchema schema, Boolean isBase)
at Bond.Expressions.SerializerTransform2.Struct(IParser parser, RuntimeSchema schema) at Bond.Expressions.SerializerTransform2.<>c__DisplayClass2.b__0(IParser p)
at Bond.Expressions.SerializerGenerator2.GenerateSerialize(Serialize serialize, IParser parser, ParameterExpression writer, Boolean inline) at Bond.Expressions.SerializerTransform2.GenerateSerialize(SerializeWithSchema serializeWithSchema, IParser parser, RuntimeSchema schema)
at Bond.Expressions.SerializerTransform2.Value(IParser parser, Expression valueType, RuntimeSchema schema) at Bond.Expressions.SerializerTransform2.<>c__DisplayClassc.<>c__DisplayClasse.b__7(IParser fieldParser, Expression fieldType)
at Bond.Expressions.Field.Bond.Expressions.IField.Value(IParser parser, Expression valueType)
at Bond.Expressions.ObjectParser.Field(ITransform transform, Expression structVar, UInt16 id, ISchemaField schemaField, IField field)
at Bond.Expressions.ObjectParser.<>c__DisplayClassc.b__7(<>f__AnonymousType02 <>h__TransparentIdentifier0, IField knownField) at System.Linq.Enumerable.<SelectManyIterator>d__43.MoveNext()
at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable1 collection)
at System.Collections.Generic.List1.AddRange(IEnumerable1 collection)
at Bond.Expressions.ObjectParser.Apply(ITransform transform)
at Bond.Expressions.SerializerTransform2.Struct(IParser parser, RuntimeSchema schema, Boolean isBase) at Bond.Expressions.SerializerTransform2.Struct(IParser parser, RuntimeSchema schema)
at Bond.Expressions.SerializerTransform2.<>c__DisplayClass2.<GenerateSerialize>b__0(IParser p) at Bond.Expressions.SerializerGenerator2.GenerateSerialize(Serialize serialize, IParser parser, ParameterExpression writer, Boolean inline)
at Bond.Expressions.SerializerTransform2.GenerateSerialize(SerializeWithSchema serializeWithSchema, IParser parser, RuntimeSchema schema) at Bond.Expressions.SerializerTransform2.Generate(IParser parser)
at Bond.Serializer1..ctor(Type type) at Bond.Serialize.Cache2..cctor()
InnerException:

@kylemc kylemc changed the title --using option in C# only allows a single type alias Serialization fails is some cases when there are multiple type aliases Jul 14, 2015
@sapek
Copy link
Contributor

sapek commented Jul 22, 2015

Multiple aliases are definitely supported, e.g. see the tests.

If you post link to your project I can take a look what might be the problem.

@sapek
Copy link
Contributor

sapek commented Jul 30, 2015

Since there are unit tests with multiple type aliases I suspect that this is not the problem so I'm closing this issue. Please open an issue with more specific information (ideally a repro).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants