internal UnionWriteContract(Type type, ContractCollection contractCollection) { if (!CanProcess(type)) { throw new ArgumentException($"Type {type} must be a union.", nameof(type)); } Members = Union.GetTypes(type) .Select(t => new Member(UnionEncoding.GetTypeName(t), contractCollection.GetOrAddWriteContract(t))) .OrderBy(m => m.Id, StringComparer.OrdinalIgnoreCase) .ToArray(); }