Program: 24183
Project: 24183
Buggy source:
private void generateMemberProperty(CompositeTypeDefn context,ElementDefn member,int order) throws Exception {
  TypeRef tref=GeneratorUtils.getMemberTypeForElement(getDefinitions(),member);
  boolean isFhirPrimitive=Character.isLowerCase(tref.getName().charAt(0));
  boolean needsNativeProperty=(isFhirPrimitive && member.getXmlFormatHint() != XmlFormatHint.ELEMENT) || member.isPrimitiveValueElement();
  boolean hasBothPrimitiveAndElementProperty=isFhirPrimitive && !needsNativeProperty;
  String choiceType=null;
  String choices="String_Node_Str";
  if (member.isPolymorph()) {
    for (    TypeRef choiceTRef : member.getType()) {
      String name=choiceTRef.getName();
      if (name.equals(TypeRef.ELEMENT_TYPE_NAME))       choiceType="String_Node_Str";
 else       if (name.equals(TypeRef.RESOURCE_TYPE_NAME))       choiceType="String_Node_Str";
 else       choiceType="String_Node_Str";
      choices+="String_Node_Str" + GeneratorUtils.buildFullyScopedTypeName(choiceTRef) + "String_Node_Str";
    }
    if (choices.endsWith("String_Node_Str"))     choices=choices.substring(0,choices.length() - 1);
  }
  ln("String_Node_Str");
  ln("String_Node_Str" + member.getAnnotation().getShortDefinition());
  ln("String_Node_Str");
  ln("String_Node_Str" + member.getName() + "String_Node_Str");
  if (member.isPrimitiveValueElement())   nl("String_Node_Str");
  if (member.getXmlFormatHint() != XmlFormatHint.ELEMENT)   nl("String_Node_Str" + member.getXmlFormatHint().getName());
  if (member.isSummaryItem())   nl("String_Node_Str");
  if (order != 0)   nl("String_Node_Str" + Integer.toString(order));
  if (choiceType != null)   nl("String_Node_Str" + choiceType);
  nl("String_Node_Str");
  if (choices.length() > 0) {
    ln("String_Node_Str");
    nl(choices);
    nl("String_Node_Str");
  }
  if (!member.isPolymorph() && member.getType().get(0).getName().equals("String_Node_Str")) {
    ln("String_Node_Str");
    boolean isNext=false;
    for (    String resParam : member.getType().get(0).getResourceParams()) {
      if (isNext)       nl("String_Node_Str");
      nl("String_Node_Str" + resParam + "String_Node_Str");
      isNext=true;
    }
    nl("String_Node_Str");
  }
  if (member.getMinCardinality() > 0 || member.getMaxCardinality() != 1) {
    ln("String_Node_Str");
    nl("String_Node_Str" + Integer.toString(member.getMinCardinality()));
    nl("String_Node_Str" + Integer.toString(member.getMaxCardinality()));
    nl("String_Node_Str");
  }
  if (needsNativeProperty)   addPrimitiveValidators(tref.getName());
  ln("String_Node_Str");
  ln("String_Node_Str");
  String memberCsType;
  if (GeneratorUtils.isCodeWithCodeList(getDefinitions(),tref))   memberCsType="String_Node_Str" + GeneratorUtils.buildFullyScopedTypeName(tref.getFullBindingRef()) + "String_Node_Str";
 else   if (needsNativeProperty)   memberCsType=GeneratorUtils.mapPrimitiveToCSharpType(tref.getName());
 else   memberCsType=GeneratorUtils.buildFullyScopedTypeName(tref);
  String singleElementCsType=memberCsType;
  if (member.getMaxCardinality() == -1)   memberCsType="String_Node_Str" + memberCsType + "String_Node_Str";
  String memberName=GeneratorUtils.generateCSharpMemberName(member);
  if (hasBothPrimitiveAndElementProperty) {
    memberName+="String_Node_Str";
  }
  member.getGeneratorAnnotations().put(CLASSGEN_MEMBER_NAME,memberName);
  member.getGeneratorAnnotations().put(CLASSGEN_MEMBER_CSTYPE,memberCsType);
  nl(memberCsType + "String_Node_Str" + memberName);
  bs("String_Node_Str");
  ln("String_Node_Str" + memberName + "String_Node_Str");
  ln("String_Node_Str" + memberName + "String_Node_Str"+ memberName+ "String_Node_Str");
  es("String_Node_Str");
  ln("String_Node_Str" + memberCsType + "String_Node_Str"+ memberName+ "String_Node_Str");
  ln();
  if (hasBothPrimitiveAndElementProperty)   generateSimpleValueAccess(member,tref,memberCsType,singleElementCsType,memberName);
}

Fixed version (ground truth):
private void generateMemberProperty(CompositeTypeDefn context,ElementDefn member,int order) throws Exception {
  TypeRef tref=GeneratorUtils.getMemberTypeForElement(getDefinitions(),member);
  boolean isFhirPrimitive=Character.isLowerCase(tref.getName().charAt(0));
  boolean needsNativeProperty=(isFhirPrimitive && member.getXmlFormatHint() != XmlFormatHint.ELEMENT) || member.isPrimitiveValueElement();
  boolean hasBothPrimitiveAndElementProperty=isFhirPrimitive && !needsNativeProperty;
  String choiceType=null;
  String choices="String_Node_Str";
  if (member.isPolymorph()) {
    for (    TypeRef choiceTRef : member.getType()) {
      String name=choiceTRef.getName();
      if (name.equals(TypeRef.ELEMENT_TYPE_NAME))       choiceType="String_Node_Str";
 else       if (name.equals(TypeRef.RESOURCE_TYPE_NAME))       choiceType="String_Node_Str";
 else       choiceType="String_Node_Str";
      choices+="String_Node_Str" + GeneratorUtils.buildFullyScopedTypeName(choiceTRef) + "String_Node_Str";
    }
    if (choices.endsWith("String_Node_Str"))     choices=choices.substring(0,choices.length() - 1);
  }
  generateDocComment(member.getAnnotation().getShortDefinition());
  ln("String_Node_Str" + member.getName() + "String_Node_Str");
  if (member.isPrimitiveValueElement())   nl("String_Node_Str");
  if (member.getXmlFormatHint() != XmlFormatHint.ELEMENT)   nl("String_Node_Str" + member.getXmlFormatHint().getName());
  if (member.isSummaryItem())   nl("String_Node_Str");
  if (order != 0)   nl("String_Node_Str" + Integer.toString(order));
  if (choiceType != null)   nl("String_Node_Str" + choiceType);
  nl("String_Node_Str");
  if (choices.length() > 0) {
    ln("String_Node_Str");
    nl(choices);
    nl("String_Node_Str");
  }
  if (!member.isPolymorph() && member.getType().get(0).getName().equals("String_Node_Str")) {
    ln("String_Node_Str");
    boolean isNext=false;
    for (    String resParam : member.getType().get(0).getResourceParams()) {
      if (isNext)       nl("String_Node_Str");
      nl("String_Node_Str" + resParam + "String_Node_Str");
      isNext=true;
    }
    nl("String_Node_Str");
  }
  if (member.getMinCardinality() > 0 || member.getMaxCardinality() != 1) {
    ln("String_Node_Str");
    nl("String_Node_Str" + Integer.toString(member.getMinCardinality()));
    nl("String_Node_Str" + Integer.toString(member.getMaxCardinality()));
    nl("String_Node_Str");
  }
  if (needsNativeProperty)   addPrimitiveValidators(tref.getName());
  ln("String_Node_Str");
  ln("String_Node_Str");
  String memberCsType;
  if (GeneratorUtils.isCodeWithCodeList(getDefinitions(),tref))   memberCsType="String_Node_Str" + GeneratorUtils.buildFullyScopedTypeName(tref.getFullBindingRef()) + "String_Node_Str";
 else   if (needsNativeProperty)   memberCsType=GeneratorUtils.mapPrimitiveToCSharpType(tref.getName());
 else   memberCsType=GeneratorUtils.buildFullyScopedTypeName(tref);
  String singleElementCsType=memberCsType;
  if (member.getMaxCardinality() == -1)   memberCsType="String_Node_Str" + memberCsType + "String_Node_Str";
  String memberName=GeneratorUtils.generateCSharpMemberName(member);
  if (hasBothPrimitiveAndElementProperty) {
    memberName+="String_Node_Str";
  }
  member.getGeneratorAnnotations().put(CLASSGEN_MEMBER_NAME,memberName);
  member.getGeneratorAnnotations().put(CLASSGEN_MEMBER_CSTYPE,memberCsType);
  nl(memberCsType + "String_Node_Str" + memberName);
  bs("String_Node_Str");
  ln("String_Node_Str" + memberName + "String_Node_Str");
  ln("String_Node_Str" + memberName + "String_Node_Str"+ memberName+ "String_Node_Str");
  es("String_Node_Str");
  ln("String_Node_Str" + memberCsType + "String_Node_Str"+ memberName+ "String_Node_Str");
  ln();
  if (hasBothPrimitiveAndElementProperty)   generateSimpleValueAccess(member,tref,memberCsType,singleElementCsType,memberName);
}