diff --git a/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs b/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs index 4d2759dc51..c1a7571a21 100644 --- a/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs +++ b/ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope public class AttributeSectionTests { [Test] - public void GlobalAttributeCSharp() + public void AttributesUsingNamespaceAlias() { string program = @"[global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] [someprefix::DesignerGenerated()] @@ -45,7 +45,7 @@ public class Form1 { } [Test] - public void AssemblyAttributeCSharp() + public void AssemblyAttribute() { string program = @"[assembly: System.Attribute()]"; AttributeSection decl = ParseUtilCSharp.ParseGlobal(program); @@ -53,30 +53,8 @@ public class Form1 { Assert.AreEqual("assembly", decl.AttributeTarget); } - [Test, Ignore("assembly/module attributes are broken")] - public void AssemblyAttributeCSharpWithNamedArguments() - { - string program = @"[assembly: Foo(1, namedArg: 2, prop = 3)]"; - AttributeSection decl = ParseUtilCSharp.ParseGlobal(program); - Assert.AreEqual("assembly", decl.AttributeTarget); - var a = decl.Attributes.Single(); - Assert.AreEqual("Foo", a.Type); - Assert.AreEqual(3, a.Arguments.Count()); - - Assert.IsTrue(a.Arguments.ElementAt(0).IsMatch(new PrimitiveExpression(1))); - Assert.IsTrue(a.Arguments.ElementAt(1).IsMatch(new NamedArgumentExpression { - Identifier = "namedArg", - Expression = new PrimitiveExpression(2) - })); - Assert.IsTrue(a.Arguments.ElementAt(2).IsMatch(new AssignmentExpression { - Left = new IdentifierExpression("prop"), - Operator = AssignmentOperatorType.Assign, - Right = new PrimitiveExpression(3) - })); - } - - [Test, Ignore("assembly/module attributes are broken")] - public void ModuleAttributeCSharp() + [Test] + public void ModuleAttribute() { string program = @"[module: System.Attribute()]"; AttributeSection decl = ParseUtilCSharp.ParseGlobal(program); @@ -85,7 +63,7 @@ public class Form1 { } [Test] - public void TypeAttributeCSharp() + public void TypeAttribute() { string program = @"[type: System.Attribute()] class Test {}"; TypeDeclaration type = ParseUtilCSharp.ParseGlobal(program); @@ -94,6 +72,22 @@ public class Form1 { Assert.AreEqual("type", decl.AttributeTarget); } + [Test] + public void TwoAttributesInSameSection() + { + ParseUtilCSharp.AssertGlobal( + @"[A, B] class Test {}", + new TypeDeclaration { + Name = "Test", + Attributes = { + new AttributeSection { + Attributes = { + new Attribute { Type = new SimpleType("A") }, + new Attribute { Type = new SimpleType("B") } + } + }}}); + } + [Test, Ignore("Parser doesn't support attributes on type parameters")] public void AttributesOnTypeParameter() { diff --git a/ICSharpCode.NRefactory/Utils/FastSerializer.cs b/ICSharpCode.NRefactory/Utils/FastSerializer.cs index 9622b887c4..1fd1053f22 100644 --- a/ICSharpCode.NRefactory/Utils/FastSerializer.cs +++ b/ICSharpCode.NRefactory/Utils/FastSerializer.cs @@ -157,6 +157,7 @@ namespace ICSharpCode.NRefactory.Utils string assemblyName = null; string typeName = null; if (type.HasElementType) { + Debug.Assert(type.IsArray); MarkType(type.GetElementType()); } else if (type.IsGenericType && !type.IsGenericTypeDefinition) { MarkType(type.GetGenericTypeDefinition()); @@ -201,6 +202,8 @@ namespace ICSharpCode.NRefactory.Utils Type type = types[i].Type; if (type.IsGenericTypeDefinition || type.HasElementType) continue; + if (typeof(ISerializable).IsAssignableFrom(type)) + continue; foreach (FieldInfo field in GetSerializableFields(type)) { MarkType(field.FieldType); }