protected void AddConstructorAssignedField( TypeReferenceBuilder type, string fieldName, ClassBuilder classBuilder, ConstructorBuilder constructorBuilder, bool skipNullCheck = false) { var paramName = fieldName.TrimStart('_'); classBuilder.AddField() .SetReadOnly() .SetName(fieldName) .SetType(type); AssignmentBuilder assignment = AssignmentBuilder .New() .SetLefthandSide(fieldName) .SetRighthandSide(paramName); if (!skipNullCheck) { assignment.AssertNonNull(); } constructorBuilder .AddCode(assignment) .AddParameter(paramName, b => b.SetType(type)); }