XmlAttributeAttribute
Posted: Wed Feb 23, 2011 3:17 pm
I have a class which is Serializable and has a XmlAttributeAttribute [XmlAttribute(AttributeName = "no")]
C# code
Cobra code
When I try compiling the above cobra code (on .net and mono), I get the following error:
Environments:
The C# version works on both.
Any ideas? I hope it is just a silly syntax error on my end.
C# code
- Code: Select all
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace TVRage.Model
{
[Serializable]
public class Season
{
[XmlAttribute(AttributeName = "no")] // This is how to do it in C# :)
public int Number { get; set; }
[XmlElement("episode")]
public List<Episode> Episodes { get; set; }
}
[Serializable, XmlRoot("episode")]
public class Episode
{
[XmlElement("epnum")]
public int Number { get; set; }
[XmlElement("seasonnum")]
public int SeasonNumber { get; set; }
[XmlElement("airdate")]
public DateTime Airdate { get; set; }
[XmlElement("title")]
public string Title { get; set; }
}
}
Cobra code
use System.Xml
use System.Xml.Linq
use System.Xml.Serialization
namespace Broadcatcher.Models
class Season has Serializable
pro number from var as int = 0
has XmlAttribute(AttributeName='no') # the problem is here
pro episodes from var as List<of Episode> = List<of Episode>()
has XmlElement('episode')
class Episode has Serializable, XmlRoot("episode")
pro number from var as int = 0
has XmlElement('epnum')
pro seasonNumber from var as int = 0
has XmlElement('seasonnum')
pro airdate from var as DateTime
has XmlElement('airdate')
pro title from var as String?
has XmlElement('title'))
When I try compiling the above cobra code (on .net and mono), I get the following error:
- Code: Select all
error: Local variables must start with a lowercase letter. This avoids collisions with other identifiers such as classes and enums.
Environments:
- Code: Select all
Windows 7 64 bit - .net 4.0 - cobra 0.8.0 post-release
Mac OS X 10.6.6 - Mono JIT compiler version 2.10 (tarball Mon Feb 14 16:04:48 MST 2011) - 0.8.0 post-release
The C# version works on both.
Any ideas? I hope it is just a silly syntax error on my end.