- if (o is ItemReference) {
- tempItems.Add (o);
- } else if (o is PropertyReference) {
- PropertyReference pr = (PropertyReference) o;
- tempItems.Add (pr.ConvertToString (project));
- } else if (o is MetadataReference) {
- tempItems.Add (o);
- } else if (o is string) {
- tempItems.Add (o);
- } else {
- throw new Exception ("Invalid type in objects collection.");
+ bool can_concat = prev_can_concat;
+
+ string str = o as string;
+ if (str != null) {
+ string trimmed_str = str.Trim ();
+ if (!IsSemicolon (str) && trimmed_str.Length > 0 && prev != null && prev is ItemReference)
+ // non-empty, non-semicolon string after item ref
+ ThrowCantConcatError (prev, str);
+
+ if (trimmed_str.Length == 0 && prev is string && IsSemicolon ((string) prev)) {
+ // empty string after a ';', ignore it
+ continue;
+ }
+
+ // empty string _after_ a itemref, not an error
+ prev_can_concat = !(str.Length > 0 && str [str.Length - 1] == ';') && trimmed_str.Length > 0;
+ AddItemsToArray (finalItems,
+ ConvertToITaskItemArrayFromString (str),
+ can_concat);
+ prev = o;
+ continue;