locked
ActivityMarkupSerializer bug? RRS feed

  • Question

  • Hi,

    I use the following code:

    [TestMethod]
    public void TestActivitySerialization()
    {
        var sb = new StringBuilder();
        using (XmlWriter writer = XmlTextWriter.Create(sb))
        {
            ActivityMarkupSerializer serializer = new ActivityMarkupSerializer();
            Activity activity = new WriteLine { Text = "foo" };
            serializer.Serialize(writer, activity);
        }
        ActivityMarkupSerializer deserializer = new ActivityMarkupSerializer();
        WriteLine result;
        using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(sb.ToString())))
        {
            using (XmlTextReader xmlTextReader = new XmlTextReader(ms))
            {
                result = deserializer.Deserialize(xmlTextReader) as WriteLine;
            }
        }
        Assert.AreEqual("foo", result.Text);
    }
    

    The test fails because test.Text is null.

    This is the WriteLine Activity Serialization:

    <?xml version="1.0" encoding="utf-16"?><ns0:WriteLine DisplayName="WriteLine" xmlns:ns0="clr-namespace:System.Activities.Statements;Assembly=System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
     <ns0:WriteLine.Text>
      <ns1:InArgument_x0060_1 xmlns:ns1="clr-namespace:System.Activities;Assembly=System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
       <ns1:InArgument_x0060_1.Expression>
        <ns2:Literal_x0060_1 DisplayName="Literal&lt;String&gt;" Value="foo" xmlns:ns2="clr-namespace:System.Activities.Expressions;Assembly=System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
       </ns1:InArgument_x0060_1.Expression>
      </ns1:InArgument_x0060_1>
     </ns0:WriteLine.Text>
    </ns0:WriteLine>

    What am I doing wrong?

    Thursday, March 31, 2011 12:11 PM

Answers