locked
Generic Array variables don't work RRS feed

  • General discussion

  • I have a workflow with a variable that isn't working.  It appears to be a workflow editor bug.

    If I create a variable of type Tuple(Of string, string)[] it won't allow me to save the workflow.  I managed to look at how the xaml was generated and it created the variable of type Tuple[](Of string, string).

    What is the correct behavior?  Where should it put the []?

    • Changed type Andrew_Zhu Monday, July 25, 2011 6:44 AM no reply
    Monday, July 18, 2011 5:17 PM

All replies

  • Hi,

    ->"I have a workflow with a variable that isn't working. It appears to be a workflow editor bug."
    Do you mean workflow designer in VS2010? have you added the external dll reference to the project?

    Regards
    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    Friday, July 22, 2011 1:09 AM
  • Yes, I do mean the workflow designer in VS2010.

    The external reference works fine.  If I have a variable as the generic type it works.  If the variable is an array of the generic type, then it fails.

    Friday, July 29, 2011 5:35 PM
  • If you save you get this right?:


    ---------------------------
    Microsoft Visual Studio
    ---------------------------
    'Character '(' was unexpected in string 's:Tuple[](x:String, x:String)'. Invalid XAML type name.' Line number '6' and line position '17'.
    ---------------------------
    OK
    ---------------------------

    I tried this out and I think you're probably right about it putting the [] in the wrong place, since it can reload the s:Tuple(x:String, x:String)[] syntax. Even if you fix the XAML temporarily it won't fix the workflow saving issue, I can't think of a good workaround here. :-(

    Tim

    Tuesday, August 16, 2011 2:20 AM
  • Hmmm what about a custom persistence service that writes the Xaml to a stringstream then does a regex or parse to fix the issues before committing to disk?  Perhaps a bit overenginered but it would be easy to take out when a fix comes out, and has zero impact on the rest of the code base

     

    What do you think Tim?

    Tuesday, August 16, 2011 2:37 AM
  • @Frank,

    If you mean using IDocumentPersistenceService? Then it does sound a bit on the overengineered side... But also I don't know how to recommend plugging in a custom persistence service into the WF Designer instance in VS, the VS WF designer isn't exposed publically for extensibility this way.

    Tuesday, August 16, 2011 5:05 AM
  • @diltsman

    This isn't great from the point of view it might affect the worfklow design, but is using List<Tuple<string,string>> instead be an option for you?
    Tim



    Tuesday, August 16, 2011 5:38 AM
  • As everybody has obviously determined, this is definitely a bug!  But before you try to find a workaround, is this really the best place to use a Tuple?  MyClass[] seems to work fine (where MyClass is a class with two string properties).  Even if the scope of the variable is only within a small section of the workflow I think you should use a named type.  It makes the workflow more understandable when you can assign names to your class members.  Even if you name the variable something descriptive will it be intuitive later on to you or another developer what the first and second elements of Tuple<string,string> are from within the workflow designer? 

     


    Tom Overton
    Tuesday, August 16, 2011 8:47 AM
  • If you don't want to use a list then assigning the array to an IEnumerable<Tuple<... works fine
    Monday, June 11, 2012 5:02 PM