How can I prevent CompileAssemblyFromSource from leaking memory?

I think I have a working solution. Thanks to everyone for pointing me in the right direction (I hope). Assemblies can’t be unloaded directly, but AppDomains can. I created a helper library that gets loaded in a new AppDomain and is able to compile a new assembly from code. Here’s what the class in that … Read more

Why is Go json.Marshal rejecting these struct tags? What is proper syntax for json tags? [duplicate]

Oh my goodness! I just figured it out. There is no space allowed between json: and the field name “name”. The “go vet” error message (“bad syntax”) is remarkably unhelpful. The following code works. Can you see the difference? package main import ( “encoding/json” “fmt” ) type Person struct { Name string `json:”name”` Age int … Read more

Is there a package to marshal in and out of x-www-form-urlencoding in golang

gorilla/schema is popular and well maintained: e.g. func FormHandler(w http.RequestWriter, r *http.Request) { err := r.ParseForm() if err != nil { // handle error } person := new(Person) // Person being a struct type decoder := schema.NewDecoder() err = decoder.Decode(person, r.Form) if err != nil { // handle error } } goforms is also an … Read more

Difference between Microsoft’s Bond and Google’s Protocol Buffers [closed]

In general, Bond has better type system and supports multiple protocols. In particular, pros are: Bond supports generics Bond has different types to represent collections: vector<T>, map<T>, list<T> Bond supports type-safe lazy deserialization (bonded<T>) Bond supports multiple formats (fast binary, compact binary, XML, JSON) + marshaling and transcoding Cons: Bond doesn’t support different types for … Read more

Why it is called Marshalling? [duplicate]

Because it’s not the same thing. From Wikipedia: In computer science, marshalling (sometimes spelled marshaling, similar to serialization) is the process of transforming the memory representation of an object to a data format suitable for storage or transmission. It is typically used when data must be moved between different parts of a computer program or … Read more

Custom MarshalJSON() never gets called in Go

In this part of the code, ms gets copied into an interface{} variable: // Trying another method (UNSUCCESSFUL) if ret, err := json.Marshal(ms); err != nil { The problem is that this variable does not implement the json.Marshaler interface, since MarshalJSON is not in the method set for myStruct (only for *myStruct). The fix is … Read more

How to fix Unmarshalling unknown type code XXX at offset YYY in Android?

There’s some rules for write and read parcelables. 1- Be careful about type mismatch. If you write int, don’t try to read long etc. 2- Be careful about order of writes and reads. Objects must be at the same sort order when reading and writing. Both of these can cause “Unmarshalling unknown type code”.

How to marshall and unmarshall a Parcelable to a byte array with help of Parcel?

First create a helper class ParcelableUtil.java: public class ParcelableUtil { public static byte[] marshall(Parcelable parceable) { Parcel parcel = Parcel.obtain(); parceable.writeToParcel(parcel, 0); byte[] bytes = parcel.marshall(); parcel.recycle(); return bytes; } public static Parcel unmarshall(byte[] bytes) { Parcel parcel = Parcel.obtain(); parcel.unmarshall(bytes, 0, bytes.length); parcel.setDataPosition(0); // This is extremely important! return parcel; } public static <T> … Read more

Why does JAXB need a no arg constructor for marshalling?

When a JAXB (JSR-222) implementation initializes its metadata it ensures that it can support both marshalling and unmarshalling. For POJO classes that do not have a no-arg constructor you can use a type level XmlAdapter to handle it: http://blog.bdoughan.com/2010/12/jaxb-and-immutable-objects.html java.sql.Date is not supported by default (although in EclipseLink JAXB (MOXy) it is). This can also … Read more

tech