public IType GetArrayType(IReturnType elementType, MonoDevelop.Projects.Dom.Output.Ambience ambience) { // Create a fake class which sublcasses System.Array and implements IList<T> DomType t = new DomType(ambience.GetString(elementType, MonoDevelop.Projects.Dom.Output.OutputFlags.UseFullName) + "[]"); // set the compilation unit of the array type to that of the element type - it's required for jumping to the declaration of the type. IType eType = GetType(elementType); if (eType != null) { t.CompilationUnit = eType.CompilationUnit; } t.Resolved = true; t.BaseType = new DomReturnType("System.Array"); t.ClassType = ClassType.Class; t.Modifiers = Modifiers.Public; t.SourceProjectDom = this; DomProperty indexer = new DomProperty(); indexer.Name = "Item"; indexer.SetterModifier = indexer.GetterModifier = Modifiers.Public; indexer.PropertyModifier |= PropertyModifier.IsIndexer; indexer.Add(new DomParameter(indexer, "index", DomReturnType.Int32)); indexer.ReturnType = elementType; t.Add(indexer); DomReturnType listType = new DomReturnType("System.Collections.Generic.IList", false, new IReturnType [] { elementType }); t.AddInterfaceImplementation(listType); return(t); }
public override object VisitIndexerDeclaration (ICSharpCode.NRefactory.Ast.IndexerDeclaration indexerDeclaration, object data) { DomProperty indexer = new DomProperty (); indexer.Name = "this"; indexer.Documentation = RetrieveDocumentation (indexerDeclaration.StartLocation.Line); indexer.PropertyModifier |= PropertyModifier.IsIndexer; indexer.Location = ConvertLocation (indexerDeclaration.StartLocation); indexer.BodyRegion = ConvertRegion (indexerDeclaration.EndLocation, indexerDeclaration.BodyEnd); indexer.GetterModifier = indexer.SetterModifier = ConvertModifiers (indexerDeclaration.Modifier); indexer.ReturnType = ConvertReturnType (indexerDeclaration.TypeReference); indexer.Add (ConvertParameterList (indexer, indexerDeclaration.Parameters)); AddAttributes (indexer, indexerDeclaration.Attributes); AddExplicitInterfaces (indexer, indexerDeclaration.InterfaceImplementations); if (indexerDeclaration.HasGetRegion) { indexer.PropertyModifier |= PropertyModifier.HasGet; if (indexerDeclaration.GetRegion.Modifier != ICSharpCode.NRefactory.Ast.Modifiers.None) indexer.GetterModifier = ConvertModifiers (indexerDeclaration.GetRegion.Modifier); indexer.GetRegion = ConvertRegion (indexerDeclaration.GetRegion.StartLocation, indexerDeclaration.GetRegion.EndLocation); } if (indexerDeclaration.HasSetRegion) { indexer.PropertyModifier |= PropertyModifier.HasSet; if (indexerDeclaration.SetRegion.Modifier != ICSharpCode.NRefactory.Ast.Modifiers.None) indexer.SetterModifier = ConvertModifiers (indexerDeclaration.SetRegion.Modifier); indexer.SetRegion = ConvertRegion (indexerDeclaration.SetRegion.StartLocation, indexerDeclaration.SetRegion.EndLocation); } indexer.DeclaringType = typeStack.Peek (); typeStack.Peek ().Add (indexer); return null; }
public override object VisitPropertyDeclaration (ICSharpCode.NRefactory.Ast.PropertyDeclaration propertyDeclaration, object data) { DomProperty property = new DomProperty (); property.Name = propertyDeclaration.Name; property.Documentation = RetrieveDocumentation (propertyDeclaration.StartLocation.Line); property.Location = ConvertLocation (propertyDeclaration.StartLocation); property.BodyRegion = ConvertRegion (propertyDeclaration.EndLocation, propertyDeclaration.BodyEnd); property.GetterModifier = property.SetterModifier = ConvertModifiers (propertyDeclaration.Modifier); property.ReturnType = ConvertReturnType (propertyDeclaration.TypeReference); AddAttributes (property, propertyDeclaration.Attributes); AddExplicitInterfaces (property, propertyDeclaration.InterfaceImplementations); if (propertyDeclaration.HasGetRegion) { property.PropertyModifier |= PropertyModifier.HasGet; if (propertyDeclaration.GetRegion.Modifier != ICSharpCode.NRefactory.Ast.Modifiers.None) property.GetterModifier = ConvertModifiers (propertyDeclaration.GetRegion.Modifier); property.GetRegion = ConvertRegion (propertyDeclaration.GetRegion.StartLocation, propertyDeclaration.GetRegion.EndLocation); } if (propertyDeclaration.HasSetRegion) { property.PropertyModifier |= PropertyModifier.HasSet; if (propertyDeclaration.SetRegion.Modifier != ICSharpCode.NRefactory.Ast.Modifiers.None) property.SetterModifier = ConvertModifiers (propertyDeclaration.SetRegion.Modifier); property.SetRegion = ConvertRegion (propertyDeclaration.SetRegion.StartLocation, propertyDeclaration.SetRegion.EndLocation); } property.DeclaringType = typeStack.Peek (); typeStack.Peek ().Add (property); return null; }
public void ReadWritePropertyTest() { DomProperty input = new DomProperty(); input.Name = "Test"; input.PropertyModifier = PropertyModifier.IsIndexer | PropertyModifier.HasGet | PropertyModifier.HasSet; MemoryStream ms = new MemoryStream(); BinaryWriter writer = new BinaryWriter(ms); DomPersistence.Write(writer, DefaultNameEncoder, input); byte[] bytes = ms.ToArray(); DomProperty result = DomPersistence.ReadProperty(CreateReader(bytes), DefaultNameDecoder, null); Assert.AreEqual("Test", result.Name); Assert.AreEqual(true, result.IsIndexer); Assert.AreEqual(true, result.HasGet); Assert.AreEqual(true, result.HasSet); }
public static DomProperty ReadProperty(BinaryReader reader, INameDecoder nameTable) { DomProperty result = new DomProperty(); // ReadMemeberInformation (changed for storing getter & setter modifiers) result.Name = ReadString(reader, nameTable); result.Documentation = ReadString(reader, nameTable); result.GetterModifier = (Modifiers)reader.ReadUInt32(); result.SetterModifier = (Modifiers)reader.ReadUInt32(); result.Location = ReadLocation(reader, nameTable); uint count = ReadUInt(reader, 1000); while (count-- > 0) { result.Add(ReadAttribute(reader, nameTable)); } // End uint explicitInterfaces = ReadUInt(reader, 500); while (explicitInterfaces-- > 0) { result.AddExplicitInterface(ReadReturnType(reader, nameTable)); } uint arguments = ReadUInt(reader, 5000); while (arguments-- > 0) { result.Add(ReadParameter(reader, nameTable)); } result.BodyRegion = ReadRegion(reader, nameTable); result.ReturnType = ReadReturnType(reader, nameTable); result.PropertyModifier = (PropertyModifier)reader.ReadInt32(); result.GetRegion = ReadRegion(reader, nameTable); result.SetRegion = ReadRegion(reader, nameTable); return(result); }
IType CreateAnonymousClass(CollectionInitializerExpression initializer) { DomType result; if (!anonymousTypes.TryGetValue(initializer, out result)) { result = new AnonymousType(); result.SourceProjectDom = resolver.Dom; foreach (Expression expr in initializer.CreateExpressions) { var oldPos = resolver.ResolvePosition; if (!expr.StartLocation.IsEmpty) { resolver.resolvePosition = new DomLocation(expr.StartLocation.Line + resolver.CallingMember.Location.Line - 1, expr.StartLocation.Column - 1); } DomProperty newProperty = new DomProperty(GetAnonymousTypeFieldName(expr), MonoDevelop.Projects.Dom.Modifiers.Public, DomLocation.Empty, DomRegion.Empty, ResolveType(expr)); newProperty.DeclaringType = result; result.Add(newProperty); resolver.resolvePosition = oldPos; } anonymousTypes[initializer] = result; } return(result); }
IType CreateAnonymousClass (CollectionInitializerExpression initializer) { DomType result; if (!anonymousTypes.TryGetValue (initializer, out result)) { result = new AnonymousType (); result.SourceProjectDom = resolver.Dom; foreach (Expression expr in initializer.CreateExpressions) { var oldPos = resolver.ResolvePosition; if (!expr.StartLocation.IsEmpty) resolver.resolvePosition = new DomLocation (expr.StartLocation.Line + resolver.CallingMember.Location.Line, expr.StartLocation.Column); DomProperty newProperty = new DomProperty (GetAnonymousTypeFieldName (expr), MonoDevelop.Projects.Dom.Modifiers.Public, DomLocation.Empty, DomRegion.Empty, ResolveType (expr)); newProperty.DeclaringType = result; result.Add (newProperty); resolver.resolvePosition = oldPos; } anonymousTypes[initializer] = result; } return result; }
public override ParsedDocument Parse(ProjectDom dom, string fileName, string content) { ParsedDocument doc = new ParsedDocument(fileName); if (null == doc.CompilationUnit) { doc.CompilationUnit = new CompilationUnit(fileName); } CompilationUnit cu = (CompilationUnit)doc.CompilationUnit; DomType currentFile = null; DomProperty currentRegion = null; string eol = Environment.NewLine; Match eolMatch = eolExpression.Match(content); if (eolMatch != null && eolMatch.Success) { eol = eolMatch.Groups["eol"].Value; } string[] lines = content.Split(new string[] { eol }, StringSplitOptions.None); int linenum = 1; Match lineMatch; foreach (string line in lines) { lineMatch = fileHeaderExpression.Match(line.Trim()); if (lineMatch != null && lineMatch.Success) { if (currentFile != null) // Close out previous file region { currentFile.BodyRegion = new DomRegion(currentFile.BodyRegion.Start.Line, currentFile.BodyRegion.Start.Column, linenum - 1, int.MaxValue); } if (currentRegion != null) // Close out previous chunk region { currentRegion.BodyRegion = new DomRegion(currentRegion.BodyRegion.Start.Line, currentRegion.BodyRegion.Start.Column, linenum - 1, int.MaxValue); } // Create new file region currentFile = new DomType(cu, ClassType.Unknown, Modifiers.None, lastToken(lineMatch.Groups["filepath"].Value), new DomLocation(linenum, 1), string.Empty, new DomRegion(linenum, line.Length + 1, linenum, int.MaxValue)); cu.Add(currentFile); } else { lineMatch = chunkExpression.Match(line); if (lineMatch != null && lineMatch.Success && currentFile != null) { if (currentRegion != null) // Close out previous chunk region { currentRegion.BodyRegion = new DomRegion(currentRegion.BodyRegion.Start.Line, currentRegion.BodyRegion.Start.Column, linenum - 1, int.MaxValue); } // Create new chunk region currentRegion = new DomProperty(lineMatch.Groups["chunk"].Value, Modifiers.None, new DomLocation(linenum, 1), new DomRegion(linenum, line.Length + 1, linenum, int.MaxValue), null); currentFile.Add(currentRegion); } } ++linenum; } // Close out trailing regions if (currentFile != null) { currentFile.BodyRegion = new DomRegion(currentFile.BodyRegion.Start.Line, currentFile.BodyRegion.Start.Column, Math.Max(1, linenum - 2), int.MaxValue); } if (currentRegion != null) { currentRegion.BodyRegion = new DomRegion(currentRegion.BodyRegion.Start.Line, currentRegion.BodyRegion.Start.Column, Math.Max(1, linenum - 2), int.MaxValue); } return(doc); }
public override ParsedDocument Parse (ProjectDom dom, string fileName, string content) { ParsedDocument doc = new ParsedDocument (fileName); if(null == doc.CompilationUnit) doc.CompilationUnit = new CompilationUnit (fileName); CompilationUnit cu = (CompilationUnit)doc.CompilationUnit; DomType currentFile = null; DomProperty currentRegion = null; string eol = Environment.NewLine; Match eolMatch = eolExpression.Match (content); if (eolMatch != null && eolMatch.Success) eol = eolMatch.Groups["eol"].Value; string[] lines = content.Split (new string[]{eol}, StringSplitOptions.None); int linenum = 1; Match lineMatch; foreach (string line in lines) { lineMatch = fileHeaderExpression.Match (line.Trim()); if (lineMatch != null && lineMatch.Success) { if (currentFile != null) // Close out previous file region currentFile.BodyRegion = new DomRegion (currentFile.BodyRegion.Start.Line, currentFile.BodyRegion.Start.Column, linenum-1, int.MaxValue); if (currentRegion != null) // Close out previous chunk region currentRegion.BodyRegion = new DomRegion (currentRegion.BodyRegion.Start.Line, currentRegion.BodyRegion.Start.Column, linenum-1, int.MaxValue); // Create new file region currentFile = new DomType (cu, ClassType.Unknown, Modifiers.None, lastToken (lineMatch.Groups["filepath"].Value), new DomLocation (linenum, 1), string.Empty, new DomRegion (linenum, line.Length+1, linenum, int.MaxValue)); cu.Add (currentFile); } else { lineMatch = chunkExpression.Match (line); if (lineMatch != null && lineMatch.Success) { if (currentRegion != null) // Close out previous chunk region currentRegion.BodyRegion = new DomRegion (currentRegion.BodyRegion.Start.Line, currentRegion.BodyRegion.Start.Column, linenum-1, int.MaxValue); // Create new chunk region currentRegion = new DomProperty (lineMatch.Groups["chunk"].Value, Modifiers.None, new DomLocation (linenum, 1), new DomRegion (linenum, line.Length+1, linenum, int.MaxValue), null); currentFile.Add (currentRegion); } } ++linenum; } // Close out trailing regions if (currentFile != null) currentFile.BodyRegion = new DomRegion (currentFile.BodyRegion.Start.Line, currentFile.BodyRegion.Start.Column, Math.Max (1, linenum-2), int.MaxValue); if (currentRegion != null) currentRegion.BodyRegion = new DomRegion (currentRegion.BodyRegion.Start.Line, currentRegion.BodyRegion.Start.Column, Math.Max (1, linenum-2), int.MaxValue); return doc; }
public void TestDomProperty() { WebDriver.Setup(x => x.FindElement(It.IsAny <By>()).GetDomProperty(It.IsAny <string>())).Returns("blank"); Actor.AsksFor(DomProperty.Of(Locator, "target")).Should().Be("blank"); }
public override void Visit (Property p) { DomProperty property = new DomProperty (); property.Name = ConvertQuoted (p.MemberName.Name); property.Documentation = RetrieveDocumentation (p.Location.Row); property.Location = Convert (p.MemberName.Location); property.GetterModifier = property.SetterModifier = ConvertModifiers (p.ModFlags); var location = LocationsBag.GetMemberLocation (p); if (location != null && location.Count >= 1) { var endLoc = location.Count == 1 ? location[0] : location[location.Count - 1]; property.BodyRegion = ConvertRegion (location[0], endLoc); } else { property.BodyRegion = DomRegion.Empty; } property.ReturnType = ConvertReturnType (p.TypeName); AddAttributes (property, p.OptAttributes, p); AddExplicitInterfaces (property, p); if (p.Get != null) { property.PropertyModifier |= PropertyModifier.HasGet; if ((p.Get.ModFlags & Mono.CSharp.Modifiers.AccessibilityMask) != 0) property.GetterModifier = ConvertModifiers (p.Get.ModFlags); if (p.Get.Block != null) { property.GetRegion = ConvertRegion (p.Get.Location, p.Get.Block.EndLocation); } else { var getLocation = LocationsBag.GetMemberLocation (p.Get); property.GetRegion = ConvertRegion (p.Get.Location, getLocation.Count > 0 ? getLocation[0] : p.Get.Location); } } if (p.Set != null) { property.PropertyModifier |= PropertyModifier.HasSet; if ((p.Set.ModFlags & Mono.CSharp.Modifiers.AccessibilityMask) != 0) property.SetterModifier = ConvertModifiers (p.Set.ModFlags); if (p.Set.Block != null) { property.SetRegion = ConvertRegion (p.Set.Location, p.Set.Block.EndLocation); } else { var setLocation = LocationsBag.GetMemberLocation (p.Set); property.SetRegion = ConvertRegion (p.Set.Location, setLocation.Count > 0 ? setLocation[0] : p.Set.Location); } } property.DeclaringType = typeStack.Peek (); typeStack.Peek ().Add (property); }
public static DomProperty ReadProperty (BinaryReader reader, INameDecoder nameTable, IDomObjectTable objectTable) { DomProperty result = new DomProperty (); // ReadMemeberInformation (changed for storing getter & setter modifiers) result.Name = ReadString (reader, nameTable); result.Documentation = ReadString (reader, nameTable); result.GetterModifier = (Modifiers)reader.ReadUInt32(); result.SetterModifier = (Modifiers)reader.ReadUInt32(); result.Location = ReadLocation (reader, nameTable); uint count = ReadUInt (reader, 1000); while (count-- > 0) result.Add (ReadAttribute (reader, nameTable, objectTable)); // End uint explicitInterfaces = ReadUInt (reader, 500); while (explicitInterfaces-- > 0) { result.AddExplicitInterface (ReadReturnType (reader, nameTable, objectTable)); } uint arguments = ReadUInt (reader, 5000); while (arguments-- > 0) { result.Add (ReadParameter (reader, nameTable, objectTable)); } result.BodyRegion = ReadRegion (reader, nameTable); result.ReturnType = ReadReturnType (reader, nameTable, objectTable); result.PropertyModifier = (PropertyModifier)reader.ReadInt32 (); result.GetRegion = ReadRegion (reader, nameTable); result.SetRegion = ReadRegion (reader, nameTable); return result; }
public void ReadWritePropertyTest () { DomProperty input = new DomProperty (); input.Name = "Test"; input.PropertyModifier = PropertyModifier.IsIndexer | PropertyModifier.HasGet | PropertyModifier.HasSet; MemoryStream ms = new MemoryStream (); BinaryWriter writer = new BinaryWriter (ms); DomPersistence.Write (writer, DefaultNameEncoder, input); byte[] bytes = ms.ToArray (); DomProperty result = DomPersistence.ReadProperty (CreateReader (bytes), DefaultNameDecoder); Assert.AreEqual ("Test", result.Name); Assert.AreEqual (true, result.IsIndexer); Assert.AreEqual (true, result.HasGet); Assert.AreEqual (true, result.HasSet); }
public void TestZeroElements() { SetUpFindElementsReturnsEmpty(); Actor.Invoking(x => x.AsksFor(DomProperty.Of(Locator, "target"))).Should().Throw <WaitingException <bool> >(); }
public override void Visit (Indexer i) { DomProperty indexer = new DomProperty (); indexer.PropertyModifier |= PropertyModifier.IsIndexer; indexer.Name = "this"; indexer.Documentation = RetrieveDocumentation (i.Location.Row); indexer.Location = Convert (i.Location); indexer.GetterModifier = indexer.SetterModifier = ConvertModifiers (i.ModFlags); var location = LocationsBag.GetMemberLocation (i); if (location != null && location.Count >= 1) { var endLoc = location.Count == 1 ? location[0] : location[location.Count - 1]; indexer.BodyRegion = ConvertRegion (location[0], endLoc); } else { indexer.BodyRegion = DomRegion.Empty; } indexer.ReturnType = ConvertReturnType (i.TypeName); AddParameter (indexer, i.ParameterInfo); AddAttributes (indexer, i.OptAttributes, i); AddExplicitInterfaces (indexer, i); if (i.Get != null) { indexer.PropertyModifier |= PropertyModifier.HasGet; if ((i.Get.ModFlags & Mono.CSharp.Modifiers.AccessibilityMask) != 0) indexer.GetterModifier = ConvertModifiers (i.Get.ModFlags); if (i.Get.Block != null) { indexer.GetRegion = ConvertRegion (i.Get.Location, i.Get.Block.EndLocation); } else { var getLocation = LocationsBag.GetMemberLocation (i.Get); indexer.GetRegion = ConvertRegion (i.Get.Location, getLocation.Count > 0 ? getLocation[0] : i.Get.Location); } } if (i.Set != null) { indexer.PropertyModifier |= PropertyModifier.HasSet; if ((i.Set.ModFlags & Mono.CSharp.Modifiers.AccessibilityMask) != 0) indexer.SetterModifier = ConvertModifiers (i.Set.ModFlags); if (i.Set.Block != null) { indexer.SetRegion = ConvertRegion (i.Set.Location, i.Set.Block.EndLocation); } else { var setLocation = LocationsBag.GetMemberLocation (i.Set); indexer.SetRegion = ConvertRegion (i.Set.Location, setLocation.Count > 0 ? setLocation[0] : i.Set.Location); } } indexer.DeclaringType = typeStack.Peek (); typeStack.Peek ().Add (indexer); }
static DomType ReadTypeInternal(BinaryReader reader, INameDecoder nameTable) { uint typeCount = ReadUInt(reader, 1000); if (typeCount > 1) { CompoundType compoundResult = new CompoundType(); while (typeCount-- > 0) { compoundResult.AddPart(ReadTypeInternal(reader, nameTable)); } return(compoundResult); } DomType result = new DomType(); ReadMemberInformation(reader, nameTable, result); // bool verbose = result.Name == "CopyDelegate"; // if (verbose) System.Console.WriteLine("read type:" + result.Name); result.TypeModifier = (TypeModifier)reader.ReadUInt32(); result.BodyRegion = ReadRegion(reader, nameTable); string compilationUnitFileName = ReadString(reader, nameTable); result.CompilationUnit = new CompilationUnit(compilationUnitFileName); result.Namespace = ReadString(reader, nameTable); result.ClassType = (ClassType)reader.ReadUInt32(); result.BaseType = ReadReturnType(reader, nameTable); // implemented interfaces long count = ReadUInt(reader, 5000); // if (verbose) System.Console.WriteLine("impl. interfaces:" + count); while (count-- > 0) { result.AddInterfaceImplementation(ReadReturnType(reader, nameTable)); } // innerTypes // if (verbose) System.Console.WriteLine("pos:" + reader.BaseStream.Position); count = ReadUInt(reader, 10000); // if (verbose) System.Console.WriteLine("inner types:" + count); while (count-- > 0) { DomType innerType = ReadTypeInternal(reader, nameTable); innerType.DeclaringType = result; result.Add(innerType); } // fields // if (verbose) System.Console.WriteLine("pos:" + reader.BaseStream.Position); count = ReadUInt(reader, 10000); // if (verbose) System.Console.WriteLine("fields:" + count); while (count-- > 0) { DomField field = ReadField(reader, nameTable); field.DeclaringType = result; result.Add(field); } // methods // if (verbose) System.Console.WriteLine("pos:" + reader.BaseStream.Position); count = ReadUInt(reader, 10000); // if (verbose) System.Console.WriteLine("methods:" + count); while (count-- > 0) { DomMethod method = ReadMethod(reader, nameTable); method.DeclaringType = result; result.Add(method); } // properties // if (verbose) System.Console.WriteLine("pos:" + reader.BaseStream.Position); count = ReadUInt(reader, 10000); // if (verbose) System.Console.WriteLine("properties:" + count); while (count-- > 0) { DomProperty property = ReadProperty(reader, nameTable); property.DeclaringType = result; result.Add(property); } // events // if (verbose) System.Console.WriteLine("pos:" + reader.BaseStream.Position); count = ReadUInt(reader, 10000); // if (verbose) System.Console.WriteLine("events:" + count); while (count-- > 0) { DomEvent evt = ReadEvent(reader, nameTable); evt.DeclaringType = result; result.Add(evt); } // type parameters count = ReadUInt(reader, 500); while (count-- > 0) { TypeParameter tp = ReadTypeParameter(reader, nameTable); result.AddTypeParameter(tp); } return(result); }
public IType GetArrayType (IReturnType elementType, MonoDevelop.Projects.Dom.Output.Ambience ambience) { // Create a fake class which sublcasses System.Array and implements IList<T> DomType t = new DomType (ambience.GetString (elementType, MonoDevelop.Projects.Dom.Output.OutputFlags.UseFullName) + "[]"); // set the compilation unit of the array type to that of the element type - it's required for jumping to the declaration of the type. IType eType = GetType (elementType); if (eType != null) t.CompilationUnit = eType.CompilationUnit; t.Resolved = true; t.BaseType = new DomReturnType ("System.Array"); t.ClassType = ClassType.Class; t.Modifiers = Modifiers.Public; t.SourceProjectDom = this; DomProperty indexer = new DomProperty (); indexer.Name = "Item"; indexer.SetterModifier = indexer.GetterModifier = Modifiers.Public; indexer.PropertyModifier |= PropertyModifier.IsIndexer; indexer.Add (new DomParameter(indexer, "index", DomReturnType.Int32)); indexer.ReturnType = elementType; t.Add (indexer); DomReturnType listType = new DomReturnType ("System.Collections.Generic.IList", false, new IReturnType [] { elementType }); t.AddInterfaceImplementation (listType); return t; }
IType CreateAnonymousClass (CollectionInitializerExpression initializer) { DomType result = new AnonymousType (); result.SourceProjectDom = resolver.Dom; foreach (Expression expr in initializer.CreateExpressions) { DomProperty newProperty = new DomProperty (GetAnonymousTypeFieldName (expr), MonoDevelop.Projects.Dom.Modifiers.Public, DomLocation.Empty, DomRegion.Empty, ResolveType(expr)); newProperty.DeclaringType = result; result.Add (newProperty); } return result; }