/// <summary> /// Create the field in the given type /// </summary> public void Create(NetTypeDefinition declaringType, TargetFramework target) { // Do not add private fields if ((javaField.AccessFlags & FieldAccessFlags.Private) != 0) return; // Find documentation var docClass = declaringTypeBuilder.Documentation; docField = (docClass != null) ? docClass.Fields.FirstOrDefault(x => x.Name == javaField.Name) : null; //var fieldType = declaringType.IsEnum ? target.TypeNameMap.GetByType(typeof(int)) : javaField.Signature.Resolve(target, declaringTypeBuilder); NetTypeReference fieldType; if (!javaField.Signature.TryResolve(target, declaringTypeBuilder, false, out fieldType)) return; //var fieldTypeIsValueType = declaringType.IsEnum ? true : javaField.FieldType. var name = declaringTypeBuilder.GetFieldName(javaField); field = new NetFieldDefinition(); field.Name = name; field.OriginalJavaName = javaField.Name; field.FieldType = fieldType; field.Attributes = GetAttributes(javaField, false); field.Description = (docField != null) ? docField.Description : null; declaringType.Fields.Add(field); }
private static void RenameClashingField(NetFieldDefinition field) { field.Name = "@" + char.ToLower(field.Name[0]) + field.Name.Substring(1); }