Browse Source

Squashed 'NRefactory/' changes from 56fde51..b8330be

b8330be Remove parent pointer from ITypeParameter and enable sharing type parameters.
ca6b0e1 fixed primitve types.
094cac4 Added some creation constructors.
b7cd75a Fixed unit test.
9fedc31 Handled undocumented expressions.
7d4ef1a Added support for quoted identifiers.
f30490c Add some parser unit tests.
307559c Remove NextStatement/PrevStatement properties - too many properties can be confusing (e.g. a loop's EmbeddedStatement would show up next to those two properties)
90542d2 Fix parsing of query continuations for queries with multiple from clauses.
ccd06a4 Fixed query expression tests. Had to add a new node type: AnonymousTypeCreateExpression.
d4eaffb Make pattern matching AST independent from C# AST.
e8d472b Rename FixedVariableInitializer.Initializer to CountExpression (this makes it consistent with StackAllocExpression).
16715bb Renamed CSharpFormattingPolicy to CSharpFormattingOptions.
92df3e5 Fixed some TypeReferenceExpression tests.
f4450d1 Fixed some invocation expression tests.
42463a4 Fixed unit test TestIdentifierContainingEscapeSequence.
021a9fb Fixed typeofexpression tests.
bd51bee Fixed GlobalFullNamespaceGenericFieldReferenceExpressionTest.
040e164 Fixed lambdaexpression tests.
0722289 Updated mcs, fixed failing unit test.
c35eb4d Enabled typ declaration tests.
94c18d6 Fixed delegate declaration tests.
a45fa11 Fixed event declaration tests.
9083bee Fixed constructor declaration tests.
2e82144 * TypeDeclarationTests.cs: * PropertyDeclarationTests.cs: enabled property declaration tests.
873c185 Added attribute section parsing / fixed indexer declaration tests.
2353804 Fixed field declaration tests.
4e60911 Fixed method declaration tests.
58caab2 Fixed statement unit tests.
cad9d18 Fixed fixed statement.
a4ce5aa Updated mcs/fixed pointer reference expression bug.
ca77589 Fixed partial modifier.
8c7e017 Fixed UsingDeclarationTests.
293dba5 Worked on pointer reference expression.
cc209b4 Fixed ArrayObjectCreateExpression tests.
58856b1 Activated cast expression tests.
c0e20a6 Fixed qualified alias member tests.
44388b2 Fixed anonymous method tests.

git-subtree-dir: NRefactory
git-subtree-split: b8330bebd6a1cb3a2895fc924f472292bc1cf85e
pull/129/head
Daniel Grunwald 15 years ago
parent
commit
6c62b4c954
  1. 4
      ICSharpCode.NRefactory.Demo/MainForm.cs
  2. 4
      ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs
  3. 11
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/AliasReferenceExpressionTests.cs
  4. 6
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/AnonymousMethodTests.cs
  5. 4
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ArrayObjectCreateExpressionTests.cs
  6. 4
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/CastExpressionTests.cs
  7. 2
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ConditionalExpressionTests.cs
  8. 2
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/DefaultValueExpressionTests.cs
  9. 11
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/IdentifierExpressionTests.cs
  10. 2
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/InvocationExpressionTests.cs
  11. 10
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/LambdaExpressionTests.cs
  12. 20
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/MemberReferenceExpressionTests.cs
  13. 4
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/PointerReferenceExpressionTests.cs
  14. 77
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/QueryExpressionTests.cs
  15. 14
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/TypeOfExpressionTests.cs
  16. 48
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/TypeReferenceExpressionTests.cs
  17. 57
      ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs
  18. 2
      ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/DelegateDeclarationTests.cs
  19. 17
      ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/TypeDeclarationTests.cs
  20. 3
      ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/UsingDeclarationTests.cs
  21. 21
      ICSharpCode.NRefactory.Tests/CSharp/Parser/ParseUtil.cs
  22. 5
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/BlockStatementTests.cs
  23. 30
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/FixedStatementTests.cs
  24. 4
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/ForStatementTests.cs
  25. 2
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/GotoStatementTests.cs
  26. 5
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/TryCatchStatementTests.cs
  27. 18
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/UsingStatementTests.cs
  28. 191
      ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/VariableDeclarationStatementTests.cs
  29. 4
      ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/ConstructorDeclarationTests.cs
  30. 4
      ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/EventDeclarationTests.cs
  31. 15
      ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/FieldDeclarationTests.cs
  32. 4
      ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/IndexerDeclarationTests.cs
  33. 21
      ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/MethodDeclarationTests.cs
  34. 7
      ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/PropertyDeclarationTests.cs
  35. 14
      ICSharpCode.NRefactory.Tests/CSharp/Resolver/LambdaTests.cs
  36. 8
      ICSharpCode.NRefactory.Tests/CSharp/Resolver/OverloadResolutionTests.cs
  37. 14
      ICSharpCode.NRefactory.Tests/FormattingTests/TestBlankLineFormatting.cs
  38. 32
      ICSharpCode.NRefactory.Tests/FormattingTests/TestBraceStlye.cs
  39. 16
      ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs
  40. 168
      ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs
  41. 120
      ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs
  42. 40
      ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs
  43. 6
      ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs
  44. 8
      ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj
  45. 2
      ICSharpCode.NRefactory.Tests/TypeSystem/GetAllBaseTypesTest.cs
  46. 25
      ICSharpCode.NRefactory.Tests/TypeSystem/TestInterningProvider.cs
  47. 10
      ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs
  48. 84
      ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs
  49. 36
      ICSharpCode.NRefactory/CSharp/Ast/AstNodeCollection.cs
  50. 58
      ICSharpCode.NRefactory/CSharp/Ast/AstType.cs
  51. 14
      ICSharpCode.NRefactory/CSharp/Ast/DepthFirstAstVisitor.cs
  52. 18
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/AnonymousMethodExpression.cs
  53. 79
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/AnonymousTypeCreateExpression.cs
  54. 10
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/AsExpression.cs
  55. 7
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/AssignmentExpression.cs
  56. 10
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/CastExpression.cs
  57. 9
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/CheckedExpression.cs
  58. 11
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/ConditionalExpression.cs
  59. 9
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/DefaultValueExpression.cs
  60. 10
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/DirectionExpression.cs
  61. 38
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/Expression.cs
  62. 18
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/IndexerExpression.cs
  63. 18
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/InvocationExpression.cs
  64. 19
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs
  65. 4
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/NamedArgumentExpression.cs
  66. 22
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/NullReferenceExpression.cs
  67. 18
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/ObjectCreateExpression.cs
  68. 9
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/ParenthesizedExpression.cs
  69. 9
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/SizeOfExpression.cs
  70. 9
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/TypeOfExpression.cs
  71. 9
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/TypeReferenceExpression.cs
  72. 9
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/UncheckedExpression.cs
  73. 25
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/UndocumentedExpression.cs
  74. 92
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/AttributeSection.cs
  75. 13
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs
  76. 16
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs
  77. 14
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingDeclaration.cs
  78. 5
      ICSharpCode.NRefactory/CSharp/Ast/IAstVisitor.cs
  79. 10
      ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs
  80. 7
      ICSharpCode.NRefactory/CSharp/Ast/NodeType.cs
  81. 54
      ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Choice.cs
  82. 42
      ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/OptionalNode.cs
  83. 95
      ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Pattern.cs
  84. 242
      ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Placeholder.cs
  85. 36
      ICSharpCode.NRefactory/CSharp/Ast/Statements/BlockStatement.cs
  86. 11
      ICSharpCode.NRefactory/CSharp/Ast/Statements/CheckedStatement.cs
  87. 9
      ICSharpCode.NRefactory/CSharp/Ast/Statements/ReturnStatement.cs
  88. 60
      ICSharpCode.NRefactory/CSharp/Ast/Statements/Statement.cs
  89. 36
      ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs
  90. 9
      ICSharpCode.NRefactory/CSharp/Ast/Statements/ThrowStatement.cs
  91. 36
      ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs
  92. 11
      ICSharpCode.NRefactory/CSharp/Ast/Statements/UncheckedStatement.cs
  93. 8
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs
  94. 12
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs
  95. 38
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/VariableInitializer.cs
  96. 18
      ICSharpCode.NRefactory/CSharp/Formatter/AstFormattingVisitor.cs
  97. 24
      ICSharpCode.NRefactory/CSharp/Formatter/CSharpFormattingOptions.cs
  98. 125
      ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs
  99. 696
      ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs
  100. 8
      ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs
  101. Some files were not shown because too many files have changed in this diff Show More

4
ICSharpCode.NRefactory.Demo/MainForm.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
@ -126,7 +126,7 @@ namespace ICSharpCode.NRefactory.Demo @@ -126,7 +126,7 @@ namespace ICSharpCode.NRefactory.Demo
void CSharpGenerateCodeButtonClick(object sender, EventArgs e)
{
StringWriter w = new StringWriter();
OutputVisitor output = new OutputVisitor(w, new CSharpFormattingPolicy());
OutputVisitor output = new OutputVisitor(w, new CSharpFormattingOptions());
compilationUnit.AcceptVisitor(output, null);
csharpCodeTextBox.Text = w.ToString();
}

4
ICSharpCode.NRefactory.Tests/CSharp/InsertParenthesesVisitorTests.cs

@ -10,12 +10,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -10,12 +10,12 @@ namespace ICSharpCode.NRefactory.CSharp
[TestFixture]
public class InsertParenthesesVisitorTests
{
CSharpFormattingPolicy policy;
CSharpFormattingOptions policy;
[SetUp]
public void SetUp()
{
policy = new CSharpFormattingPolicy();
policy = new CSharpFormattingOptions();
}
string InsertReadable(Expression expr)

11
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/AliasReferenceExpressionTests.cs

@ -5,10 +5,11 @@ @@ -5,10 +5,11 @@
using System;
using System.IO;
using NUnit.Framework;
using ICSharpCode.NRefactory.PatternMatching;
namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
{
[TestFixture, Ignore("Aliases not yet implemented")]
[TestFixture]
public class AliasReferenceExpressionTests
{
[Test]
@ -16,12 +17,12 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -16,12 +17,12 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
{
CSharpParser parser = new CSharpParser();
AstType type = parser.ParseTypeReference(new StringReader("global::System"));
Assert.IsNotNull(
Assert.IsTrue(
new MemberType {
Target = new SimpleType("global"),
IsDoubleColon = true,
MemberName = "System"
}.Match(type)
}.IsMatch(type)
);
}
@ -29,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -29,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
public void GlobalTypeDeclaration()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("global::System.String a;");
Assert.IsNotNull(
Assert.IsTrue(
new VariableDeclarationStatement {
Type = new MemberType {
Target = new MemberType {
@ -43,7 +44,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -43,7 +44,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
Variables = {
new VariableInitializer("a")
}
}.Match(lvd)
}.IsMatch(lvd)
);
}

6
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/AnonymousMethodTests.cs

@ -34,7 +34,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -34,7 +34,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
Assert.AreEqual(0, ame.Body.Statements.Count());
}
[Test, Ignore("Parameter list is broken")]
[Test]
public void EmptyAnonymousMethod()
{
AnonymousMethodExpression ame = Parse("delegate() {}");
@ -43,14 +43,14 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -43,14 +43,14 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
Assert.IsTrue(ame.HasParameterList);
}
[Test, Ignore("Parameter list is broken")]
[Test]
public void SimpleAnonymousMethod()
{
AnonymousMethodExpression ame = Parse("delegate(int a, int b) { return a + b; }");
Assert.IsTrue(ame.HasParameterList);
Assert.AreEqual(2, ame.Parameters.Count());
Assert.AreEqual(1, ame.Body.Statements.Count());
Assert.IsTrue(ame.Body.Children.First() is ReturnStatement);
Assert.IsTrue(ame.Body.Statements.First() is ReturnStatement);
}
}
}

4
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ArrayObjectCreateExpressionTests.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
});
}
[Test, Ignore("AdditionalArraySpecifiers not yet implemented")]
[Test]
public void MultidimensionalNestedArray()
{
ParseUtilCSharp.AssertExpression(
@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
});
}
[Test, Ignore("Array initializers not yet implemented")]
[Test]
public void ImplicitlyTypedArrayCreateExpression()
{
ParseUtilCSharp.AssertExpression(

4
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/CastExpressionTests.cs

@ -6,7 +6,7 @@ using NUnit.Framework; @@ -6,7 +6,7 @@ using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
{
[TestFixture, Ignore("Port unit tests to new DOM")]
[TestFixture]
public class CastExpressionTests
{
[Test]
@ -151,7 +151,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -151,7 +151,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
});
}
[Test]
[Test, Ignore ("TODO")]
public void IntMaxValueToBigInt()
{
ParseUtilCSharp.AssertExpression(

2
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/ConditionalExpressionTests.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -30,7 +30,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
Assert.IsTrue(ce.FalseExpression is MemberReferenceExpression);
}
[Test, Ignore("crashes the parser")]
[Test]
public void ConditionalIsWithNullableExpressionTest()
{
ConditionalExpression ce = ParseUtilCSharp.ParseExpression<ConditionalExpression>("a is b? ? a() : a.B");

2
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/DefaultValueExpressionTests.cs

@ -6,7 +6,7 @@ using NUnit.Framework; @@ -6,7 +6,7 @@ using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
{
[TestFixture, Ignore("Aliases not yet implemented")]
[TestFixture]
public class DefaultValueExpressionTests
{
[Test]

11
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/IdentifierExpressionTests.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using NUnit.Framework;
using ICSharpCode.NRefactory.PatternMatching;
namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
{
@ -33,7 +34,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -33,7 +34,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
CheckIdentifier(@"\u006cexer", "lexer");
}
[Test, Ignore("Mono parser bug?")]
[Test]
public void TestIdentifierContainingEscapeSequence()
{
CheckIdentifier(@"l\U00000065xer", "lexer");
@ -61,26 +62,26 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -61,26 +62,26 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
public void GenericMethodReference()
{
IdentifierExpression ident = ParseUtilCSharp.ParseExpression<IdentifierExpression>("M<int>");
Assert.IsNotNull(
Assert.IsTrue(
new IdentifierExpression {
Identifier = "M" ,
TypeArguments = {
new PrimitiveType("int")
}
}.Match(ident));
}.IsMatch(ident));
}
[Test]
public void GenericMethodReference2()
{
IdentifierExpression ident = ParseUtilCSharp.ParseExpression<IdentifierExpression>("TargetMethod<string>");
Assert.IsNotNull(
Assert.IsTrue(
new IdentifierExpression {
Identifier = "TargetMethod" ,
TypeArguments = {
new PrimitiveType("string")
}
}.Match(ident));
}.IsMatch(ident));
}
}
}

2
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/InvocationExpressionTests.cs

@ -153,7 +153,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -153,7 +153,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
}.Invoke("Foo"));
}
[Test, Ignore("named arguments not yet supported")]
[Test]
public void InvocationWithNamedArgument()
{
ParseUtilCSharp.AssertExpression(

10
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/LambdaExpressionTests.cs

@ -9,7 +9,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -9,7 +9,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
[TestFixture]
public class LambdaExpressionTests
{
[Test, Ignore("Lambdas with expression body not yet supported")]
[Test]
public void ImplicitlyTypedExpressionBody()
{
ParseUtilCSharp.AssertExpression(
@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -20,7 +20,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
});
}
[Test, Ignore("Lambdas with expression body not yet supported")]
[Test]
public void ImplicitlyTypedExpressionBodyWithoutParenthesis()
{
ParseUtilCSharp.AssertExpression(
@ -73,7 +73,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -73,7 +73,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
}}});
}
[Test, Ignore("Lambdas with expression body not yet supported")]
[Test]
public void ExplicitlyTypedWithRefParameter()
{
ParseUtilCSharp.AssertExpression(
@ -83,14 +83,14 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -83,14 +83,14 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
new ParameterDeclaration {
ParameterModifier = ParameterModifier.Ref,
Type = new PrimitiveType("int"),
Name = "x"
Name = "i"
}
},
Body = new AssignmentExpression(new IdentifierExpression("i"), new PrimitiveExpression(1))
});
}
[Test, Ignore("Lambdas with expression body not yet supported")]
[Test]
public void LambdaExpressionContainingConditionalExpression()
{
ParseUtilCSharp.AssertExpression(

20
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/MemberReferenceExpressionTests.cs

@ -57,19 +57,23 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -57,19 +57,23 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
);
}
[Test, Ignore("Aliases not yet implemented")]
[Test]
public void GlobalFullNamespaceGenericFieldReferenceExpressionTest()
{
ParseUtilCSharp.AssertExpression(
"global::Namespace.Subnamespace.SomeClass<string>.myField",
new MemberReferenceExpression {
Target = new MemberType {
var target = new MemberType {
Target = new SimpleType("global"),
IsDoubleColon = true,
MemberName = "Namespace"
}.Member("Subnamespace"),
TypeArguments = { new PrimitiveType("string") }
}.Member("myField")
}.Member("Subnamespace").Member ("SomeClass");
target.AddChild (new PrimitiveType("string"), MemberReferenceExpression.Roles.TypeArgument);
ParseUtilCSharp.AssertExpression(
"global::Namespace.Subnamespace.SomeClass<string>.myField",
new MemberReferenceExpression {
Target = target,
MemberName = "myField"
}
);
}

4
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/PointerReferenceExpressionTests.cs

@ -9,7 +9,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -9,7 +9,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
[TestFixture]
public class PointerReferenceExpressionTests
{
[Test, Ignore("Parser bug!")]
[Test]
public void PointerReferenceExpressionTest()
{
PointerReferenceExpression pre = ParseUtilCSharp.ParseExpression<PointerReferenceExpression>("myObj.field->b");
@ -17,7 +17,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -17,7 +17,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
Assert.AreEqual("b", pre.MemberName);
}
[Test, Ignore("Parser bug!")]
[Test]
public void PointerReferenceGenericMethodTest()
{
ParseUtilCSharp.AssertExpression(

77
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/QueryExpressionTests.cs

@ -6,7 +6,7 @@ using NUnit.Framework; @@ -6,7 +6,7 @@ using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
{
[TestFixture, Ignore("Query expressions not yet implemented")]
[TestFixture]
public class QueryExpressionTests
{
[Test]
@ -125,19 +125,17 @@ select new { c.Name, o.OrderID, o.Total }", @@ -125,19 +125,17 @@ select new { c.Name, o.OrderID, o.Total }",
},
new QueryWhereClause {
Condition = new BinaryOperatorExpression {
Left = new IdentifierExpression("c").Member("OrderDate").Member("Year"),
Left = new IdentifierExpression("o").Member("OrderDate").Member("Year"),
Operator = BinaryOperatorType.Equality,
Right = new PrimitiveExpression(2005)
}
},
new QuerySelectClause {
Expression = new ObjectCreateExpression {
Initializer = new ArrayInitializerExpression {
Elements = {
new IdentifierExpression("c").Member("Name"),
new IdentifierExpression("o").Member("OrderID"),
new IdentifierExpression("o").Member("Total")
}
Expression = new AnonymousTypeCreateExpression {
Initializer = {
new IdentifierExpression("c").Member("Name"),
new IdentifierExpression("o").Member("OrderID"),
new IdentifierExpression("o").Member("Total")
}
}
}
@ -221,5 +219,66 @@ select new { c.Name, o.OrderID, o.Total }", @@ -221,5 +219,66 @@ select new { c.Name, o.OrderID, o.Total }",
}
);
}
[Test]
public void QueryContinuationWithMultipleFrom()
{
ParseUtilCSharp.AssertExpression(
"from a in b from c in d select e into f select g",
new QueryExpression {
Clauses = {
new QueryContinuationClause {
PrecedingQuery = new QueryExpression {
Clauses = {
new QueryFromClause {
Identifier = "a",
Expression = new IdentifierExpression("b")
},
new QueryFromClause {
Identifier = "c",
Expression = new IdentifierExpression("d")
},
new QuerySelectClause { Expression = new IdentifierExpression("e") }
}
},
Identifier = "f"
},
new QuerySelectClause { Expression = new IdentifierExpression("g") }
}
}
);
}
[Test]
public void MultipleQueryContinuation()
{
ParseUtilCSharp.AssertExpression(
"from a in b select c into d select e into f select g",
new QueryExpression {
Clauses = {
new QueryContinuationClause {
PrecedingQuery = new QueryExpression {
Clauses = {
new QueryContinuationClause {
PrecedingQuery = new QueryExpression {
Clauses = {
new QueryFromClause {
Identifier = "a",
Expression = new IdentifierExpression("b")
},
new QuerySelectClause { Expression = new IdentifierExpression("c") }
}
},
Identifier = "d"
},
new QuerySelectClause { Expression = new IdentifierExpression("e") }
}
},
Identifier = "f"
},
new QuerySelectClause { Expression = new IdentifierExpression("g") }
}});
}
}
}

14
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/TypeOfExpressionTests.cs

@ -24,7 +24,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -24,7 +24,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
}});
}
[Test, Ignore("Aliases not yet implemented")]
[Test]
public void GlobalTypeOfExpressionTest()
{
ParseUtilCSharp.AssertExpression(
@ -108,11 +108,17 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression @@ -108,11 +108,17 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
}});
}
[Test, Ignore("How do we represent unbound types in the AST?")]
[Test]
public void UnboundTypeOfExpressionTest()
{
TypeOfExpression toe = ParseUtilCSharp.ParseExpression<TypeOfExpression>("typeof(MyType<,>)");
throw new NotImplementedException("How do we represent unbound types in the AST?");
var type = new SimpleType("MyType");
type.AddChild (new SimpleType (), SimpleType.Roles.TypeArgument);
type.AddChild (new SimpleType (), SimpleType.Roles.TypeArgument);
ParseUtilCSharp.AssertExpression(
"typeof(MyType<,>)",
new TypeOfExpression {
Type = type
});
}
}
}

48
ICSharpCode.NRefactory.Tests/CSharp/Parser/Expression/TypeReferenceExpressionTests.cs

@ -3,44 +3,60 @@ @@ -3,44 +3,60 @@
using System;
using NUnit.Framework;
using ICSharpCode.NRefactory.PatternMatching;
namespace ICSharpCode.NRefactory.CSharp.Parser.Expression
{
[TestFixture, Ignore]
[TestFixture]
public class TypeReferenceExpressionTests
{
[Test]
public void GlobalTypeReferenceExpression()
{
/*TypeReferenceExpression tr = ParseUtilCSharp.ParseExpression<TypeReferenceExpression>("global::System");
Assert.AreEqual("System", tr.TypeReference.Type);
Assert.IsTrue(tr.TypeReference.IsGlobal);*/
throw new NotImplementedException();
TypeReferenceExpression tr = ParseUtilCSharp.ParseExpression<TypeReferenceExpression>("global::System");
Assert.IsTrue (tr.IsMatch (new TypeReferenceExpression () {
Type = new MemberType () {
Target = new SimpleType ("global"),
IsDoubleColon = true,
MemberName = "System"
}
}));
}
/* TODO
[Test]
[Test, Ignore ("Doesn't work")]
public void GlobalTypeReferenceExpressionWithoutTypeName()
{
TypeReferenceExpression tr = ParseUtilCSharp.ParseExpression<TypeReferenceExpression>("global::", true);
Assert.AreEqual("?", tr.TypeReference.Type);
Assert.IsTrue(tr.TypeReference.IsGlobal);
Assert.IsTrue (tr.IsMatch (new TypeReferenceExpression () {
Type = new MemberType () {
Target = new SimpleType ("global"),
IsDoubleColon = true,
}
}));
}
[Test]
[Test, Ignore("Primitive types as member reference target are not supported yet")]
public void IntReferenceExpression()
{
MemberReferenceExpression fre = ParseUtilCSharp.ParseExpression<MemberReferenceExpression>("int.MaxValue");
Assert.AreEqual("MaxValue", fre.MemberName);
Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type);
Assert.IsTrue (fre.IsMatch (new MemberReferenceExpression () {
Target = new TypeReferenceExpression () {
Type = new PrimitiveType("int")
},
MemberName = "MaxValue"
}));
}
[Test]
/* [Test]
public void StandaloneIntReferenceExpression()
{
// doesn't work because a = int; gives a compiler error.
// But how do we handle this case for code completion?
TypeReferenceExpression tre = ParseUtilCSharp.ParseExpression<TypeReferenceExpression>("int");
Assert.AreEqual("System.Int32", tre.TypeReference.Type);
}
*/
Assert.IsNotNull (tre.Match (new TypeReferenceExpression () {
Type = new SimpleType ("int")
}));
}*/
}
}

57
ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/AttributeSectionTests.cs

@ -3,28 +3,31 @@ @@ -3,28 +3,31 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;
using ICSharpCode.NRefactory.PatternMatching;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
{
[TestFixture, Ignore]
[TestFixture]
public class AttributeSectionTests
{
[Test, Ignore]
[Test, Ignore("Parser crash")]
public void GlobalAttributeCSharp()
{
string program = @"[global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()]
[someprefix::DesignerGenerated()]
public class Form1 {
}";
// TODO This old NRefactory test checked that [global] attributes are incorrectly applied to the following type???
//TypeDeclaration decl = ParseUtilCSharp.ParseGlobal<TypeDeclaration>(program);
//Assert.AreEqual("Microsoft.VisualBasic.CompilerServices.DesignerGenerated", decl.Attributes.First().Attributes.Single().Name);
//Assert.AreEqual("someprefix.DesignerGenerated", decl.Attributes.Last().Attributes.Single().Name);
TypeDeclaration decl = ParseUtilCSharp.ParseGlobal<TypeDeclaration>(program);
Assert.AreEqual(2, decl.Attributes.Count);
Assert.AreEqual("global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated",
decl.Attributes.First().Attributes.Single().Type.ToString());
Assert.AreEqual("someprefix::DesignerGenerated", decl.Attributes.Last().Attributes.Single().Type.ToString());
}
[Test]
[Test, Ignore("assembly/module attributes are broken")]
public void AssemblyAttributeCSharp()
{
string program = @"[assembly: System.Attribute()]";
@ -33,7 +36,7 @@ public class Form1 { @@ -33,7 +36,7 @@ public class Form1 {
Assert.AreEqual("assembly", decl.AttributeTarget);
}
[Test]
[Test, Ignore("assembly/module attributes are broken")]
public void AssemblyAttributeCSharpWithNamedArguments()
{
string program = @"[assembly: Foo(1, namedArg: 2, prop = 3)]";
@ -43,16 +46,25 @@ public class Form1 { @@ -43,16 +46,25 @@ public class Form1 {
Assert.AreEqual("Foo", a.Type);
Assert.AreEqual(3, a.Arguments.Count());
// TODO: check arguments
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]
[Test, Ignore("assembly/module attributes are broken")]
public void ModuleAttributeCSharp()
{
string program = @"[module: System.Attribute()]";
AttributeSection decl = ParseUtilCSharp.ParseGlobal<AttributeSection>(program);
Assert.AreEqual(new AstLocation(1, 1), decl.StartLocation);
Assert.AreEqual(AttributeTarget.Module, decl.AttributeTarget);
Assert.AreEqual("module", decl.AttributeTarget);
}
[Test]
@ -62,7 +74,28 @@ public class Form1 { @@ -62,7 +74,28 @@ public class Form1 {
TypeDeclaration type = ParseUtilCSharp.ParseGlobal<TypeDeclaration>(program);
AttributeSection decl = type.Attributes.Single();
Assert.AreEqual(new AstLocation(1, 1), decl.StartLocation);
Assert.AreEqual(AttributeTarget.Type, decl.AttributeTarget);
Assert.AreEqual("type", decl.AttributeTarget);
}
[Test, Ignore("Parser doesn't support attributes on type parameters")]
public void AttributesOnTypeParameter()
{
string program = @"class Test<[A,B]C> {}";
TypeDeclaration type = ParseUtilCSharp.ParseGlobal<TypeDeclaration>(program);
Assert.IsTrue(
new TypeParameterDeclaration {
Attributes = {
new AttributeSection {
Attributes = {
new Attribute { Type = new SimpleType("A") },
new Attribute { Type = new SimpleType("B") }
}
}
},
Name = "C"
}.IsMatch(type.TypeParameters.Single()));
}
// TODO: Tests for other contexts where attributes can appear
}
}

2
ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/DelegateDeclarationTests.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -26,7 +26,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
}});
}
[Test, Ignore("Generics not yet supported")]
[Test]
public void GenericDelegateDeclarationTest()
{
ParseUtilCSharp.AssertGlobal(

17
ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/TypeDeclarationTests.cs

@ -18,8 +18,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -18,8 +18,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
Assert.AreEqual(ClassType.Class, td.ClassType);
Assert.AreEqual("MyClass", td.Name);
//Assert.AreEqual("My.Base.Class", td.BaseTypes[0].Type);
Assert.Ignore("need to check base type"); // TODO
Assert.AreEqual("My.Base.Class", td.BaseTypes.First ().ToString ());
Assert.AreEqual(Modifiers.None, td.Modifiers);
}
@ -37,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -37,7 +36,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
Assert.AreEqual(2, td.EndLocation.Column, "EndLocation.Y");
}
[Test, Ignore("partial modifier is broken")]
[Test]
public void SimplePartialClassTypeDeclarationTest()
{
TypeDeclaration td = ParseUtilCSharp.ParseGlobal<TypeDeclaration>("partial class MyClass { }");
@ -47,7 +46,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -47,7 +46,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
Assert.AreEqual(Modifiers.Partial, td.Modifiers);
}
[Test, Ignore("nested classes are broken")]
[Test]
public void NestedClassesTest()
{
TypeDeclaration td = ParseUtilCSharp.ParseGlobal<TypeDeclaration>("class MyClass { partial class P1 {} public partial class P2 {} static class P3 {} internal static class P4 {} }");
@ -70,7 +69,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -70,7 +69,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
Assert.AreEqual(Modifiers.Static, td.Modifiers);
}
[Test, Ignore("Generics not yet supported")]
[Test]
public void GenericClassTypeDeclarationTest()
{
ParseUtilCSharp.AssertGlobal(
@ -83,7 +82,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -83,7 +82,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
});
}
[Test, Ignore("Constraints not yet supported")]
[Test]
public void GenericClassWithWhere()
{
ParseUtilCSharp.AssertGlobal(
@ -101,7 +100,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -101,7 +100,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
}});
}
[Test, Ignore("Generic classes not yet supported")]
[Test, Ignore ("Mono parser bug.")]
public void ComplexGenericClassTypeDeclarationTest()
{
ParseUtilCSharp.AssertGlobal(
@ -144,7 +143,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -144,7 +143,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
});
}
[Test, Ignore("Base types not yet implemented")]
[Test]
public void ComplexClassTypeDeclarationTest()
{
ParseUtilCSharp.AssertGlobal(
@ -217,7 +216,7 @@ public abstract class MyClass : MyBase, Interface1, My.Test.Interface2 @@ -217,7 +216,7 @@ public abstract class MyClass : MyBase, Interface1, My.Test.Interface2
new TypeParameterDeclaration {
Attributes = {
new AttributeSection {
AttributeTarget = AttributeTarget.Unknown,
AttributeTarget = "partial",
Attributes = { new Attribute { Type = new SimpleType("where") } }
}
},

3
ICSharpCode.NRefactory.Tests/CSharp/Parser/GeneralScope/UsingDeclarationTests.cs

@ -12,7 +12,6 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -12,7 +12,6 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
public class UsingDeclarationTests
{
[Test]
[Ignore("error reporting not yet implemented")]
public void WrongUsingTest()
{
string program = "using\n";
@ -43,7 +42,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope @@ -43,7 +42,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.GeneralScope
Assert.AreEqual("My.Name.Space", ud.Namespace);
}
[Test, Ignore("Aliases to generic types not yet supported")]
[Test]
public void UsingAliasDeclarationTest()
{
string program = "using TESTME=System;\n" +

21
ICSharpCode.NRefactory.Tests/CSharp/Parser/ParseUtil.cs

@ -1,9 +1,11 @@ @@ -1,9 +1,11 @@
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// Copyright (c) 2010 AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.IO;
using System.Linq;
using ICSharpCode.NRefactory.PatternMatching;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Parser
@ -29,7 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser @@ -29,7 +31,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser
public static void AssertGlobal(string code, AstNode expectedNode)
{
var node = ParseGlobal<AstNode>(code);
if (expectedNode.Match(node) == null) {
if (!expectedNode.IsMatch(node)) {
Assert.Fail("Expected '{0}' but was '{1}'", ToCSharp(expectedNode), ToCSharp(node));
}
}
@ -50,20 +52,19 @@ namespace ICSharpCode.NRefactory.CSharp.Parser @@ -50,20 +52,19 @@ namespace ICSharpCode.NRefactory.CSharp.Parser
public static void AssertStatement(string code, CSharp.Statement expectedStmt)
{
var stmt = ParseStatement<CSharp.Statement>(code);
if (expectedStmt.Match(stmt) == null) {
if (!expectedStmt.IsMatch(stmt)) {
Assert.Fail("Expected '{0}' but was '{1}'", ToCSharp(expectedStmt), ToCSharp(stmt));
}
}
public static T ParseExpression<T>(string expr, bool expectErrors = false) where T : AstNode
{
if (expectErrors) Assert.Ignore("errors not yet implemented");
CSharpParser parser = new CSharpParser();
AstNode parsedExpression = parser.ParseExpression(new StringReader(expr));
Assert.AreEqual(expectErrors, parser.HasErrors, "HasErrors");
if (expectErrors && parsedExpression == null)
return default (T);
Type type = typeof(T);
Assert.IsTrue(type.IsAssignableFrom(parsedExpression.GetType()), String.Format("Parsed expression was {0} instead of {1} ({2})", parsedExpression.GetType(), type, parsedExpression));
return (T)parsedExpression;
@ -72,15 +73,13 @@ namespace ICSharpCode.NRefactory.CSharp.Parser @@ -72,15 +73,13 @@ namespace ICSharpCode.NRefactory.CSharp.Parser
public static void AssertExpression(string code, CSharp.Expression expectedExpr)
{
var expr = ParseExpression<CSharp.Expression>(code);
if (expectedExpr.Match(expr) == null) {
if (!expectedExpr.IsMatch(expr)) {
Assert.Fail("Expected '{0}' but was '{1}'", ToCSharp(expectedExpr), ToCSharp(expr));
}
}
public static T ParseTypeMember<T>(string expr, bool expectErrors = false) where T : AttributedNode
{
if (expectErrors) Assert.Ignore("errors not yet implemented");
CSharpParser parser = new CSharpParser();
var members = parser.ParseTypeMembers(new StringReader(expr));
@ -95,7 +94,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser @@ -95,7 +94,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser
public static void AssertTypeMember(string code, CSharp.AttributedNode expectedMember)
{
var member = ParseTypeMember<CSharp.AttributedNode>(code);
if (expectedMember.Match(member) == null) {
if (!expectedMember.IsMatch(member)) {
Assert.Fail("Expected '{0}' but was '{1}'", ToCSharp(expectedMember), ToCSharp(member));
}
}
@ -103,7 +102,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser @@ -103,7 +102,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser
static string ToCSharp(AstNode node)
{
StringWriter w = new StringWriter();
node.AcceptVisitor(new OutputVisitor(w, new CSharpFormattingPolicy()), null);
node.AcceptVisitor(new OutputVisitor(w, new CSharpFormattingOptions()), null);
return w.ToString();
}
}

5
ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/BlockStatementTests.cs

@ -17,7 +17,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements @@ -17,7 +17,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
Assert.AreEqual(0, blockStmt.Statements.Count());
}
[Test, Ignore("position isn't correct when only parsing a block")]
[Test]
public void ComplexBlockStatementPositionTest()
{
string code = @"{
@ -30,7 +30,8 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements @@ -30,7 +30,8 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
};
}";
BlockStatement blockStmt = ParseUtilCSharp.ParseStatement<BlockStatement>(code);
Assert.AreEqual(1, blockStmt.StartLocation.Column);
// start column gets moved by ParseStatement
// Assert.AreEqual(1, blockStmt.StartLocation.Column);
Assert.AreEqual(1, blockStmt.StartLocation.Line);
Assert.AreEqual(2, blockStmt.EndLocation.Column);
Assert.AreEqual(9, blockStmt.EndLocation.Line);

30
ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/FixedStatementTests.cs

@ -6,21 +6,43 @@ using NUnit.Framework; @@ -6,21 +6,43 @@ using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
{
[TestFixture, Ignore("fixed is not implemented")]
[TestFixture]
public class FixedStatementTests
{
[Test]
public void FixedStatementTest()
{
FixedStatement fixedStmt = ParseUtilCSharp.ParseStatement<FixedStatement>("fixed (int* ptr = &myIntArr) { }");
ParseUtilCSharp.AssertStatement(
"fixed (int* ptr = &myIntArr) { }",
"fixed (int* ptr = myIntArr) { }",
new FixedStatement {
Type = new PrimitiveType("int").MakePointerType(),
Variables = {
new VariableInitializer {
Name = "ptr",
Initializer = new UnaryOperatorExpression(UnaryOperatorType.AddressOf, new IdentifierExpression("myIntArr"))
Initializer = new IdentifierExpression("myIntArr")
}
},
EmbeddedStatement = new BlockStatement()
});
}
[Test]
public void FixedStatementWithMultipleVariables()
{
ParseUtilCSharp.AssertStatement(
"fixed (int* ptr1 = &myIntArr[1], ptr2 = myIntArr) { }",
new FixedStatement {
Type = new PrimitiveType("int").MakePointerType(),
Variables = {
new VariableInitializer {
Name = "ptr1",
Initializer = new UnaryOperatorExpression(
UnaryOperatorType.AddressOf,
new IndexerExpression { Target = new IdentifierExpression("myIntArr"), Arguments = { new PrimitiveExpression(1) } })
},
new VariableInitializer {
Name = "ptr2",
Initializer = new IdentifierExpression("myIntArr")
}
},
EmbeddedStatement = new BlockStatement()

4
ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/ForStatementTests.cs

@ -10,7 +10,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements @@ -10,7 +10,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
[TestFixture]
public class ForStatementTests
{
[Test, Ignore("variable type in foreach is broken")]
[Test]
public void ForeachStatementTest()
{
ParseUtilCSharp.AssertStatement(
@ -23,7 +23,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements @@ -23,7 +23,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
});
}
[Test, Ignore("for statement is broken when Initializers.Count()!=1")]
[Test]
public void EmptyForStatementTest()
{
ForStatement forStmt = ParseUtilCSharp.ParseStatement<ForStatement>("for (;;) ;");

2
ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/GotoStatementTests.cs

@ -10,7 +10,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements @@ -10,7 +10,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
[TestFixture]
public class GotoStatementTests
{
[Test, Ignore("regular goto statement is broken")]
[Test]
public void GotoStatementTest()
{
var gotoStmt = ParseUtilCSharp.ParseStatement<GotoStatement>("goto myLabel;");

5
ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/TryCatchStatementTests.cs

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
using System;
using System.Linq;
using NUnit.Framework;
using ICSharpCode.NRefactory.PatternMatching;
namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
{
@ -66,8 +67,8 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements @@ -66,8 +67,8 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
CatchClauses = { new CatchClause { Body = new BlockStatement() } },
FinallyBlock = new BlockStatement()
};
Assert.IsNull(c1.Match(c2));
Assert.IsNull(c2.Match(c1)); // and vice versa
Assert.IsFalse(c1.IsMatch(c2));
Assert.IsFalse(c2.IsMatch(c1)); // and vice versa
}
}
}

18
ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/UsingStatementTests.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.Linq;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
@ -9,11 +10,22 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements @@ -9,11 +10,22 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
[TestFixture]
public class UsingStatementTests
{
[Test]
public void UsingStatementTest()
[Test, Ignore("Parser doesn't report the VariableDeclarationStatement")]
public void UsingStatementWithVariableDeclaration()
{
UsingStatement usingStmt = ParseUtilCSharp.ParseStatement<UsingStatement>("using (MyVar var = new MyVar()) { } ");
// TODO : Extend test.
VariableDeclarationStatement varDecl = (VariableDeclarationStatement)usingStmt.ResourceAcquisition;
Assert.AreEqual("var", varDecl.Variables.Single().Name);
Assert.IsTrue(varDecl.Variables.Single().Initializer is ObjectCreateExpression);
Assert.AreEqual("MyVar", ((SimpleType)varDecl.Type).Identifier);
Assert.IsTrue(usingStmt.EmbeddedStatement is BlockStatement);
}
public void UsingStatementWithExpression()
{
UsingStatement usingStmt = ParseUtilCSharp.ParseStatement<UsingStatement>("using (new MyVar()) { } ");
Assert.IsTrue(usingStmt.ResourceAcquisition is ObjectCreateExpression);
Assert.IsTrue(usingStmt.EmbeddedStatement is BlockStatement);
}
}
}

191
ICSharpCode.NRefactory.Tests/CSharp/Parser/Statements/VariableDeclarationStatementTests.cs

@ -3,11 +3,12 @@ @@ -3,11 +3,12 @@
using System;
using System.Linq;
using ICSharpCode.NRefactory.PatternMatching;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
{
[TestFixture, Ignore]
[TestFixture]
public class VariableDeclarationStatementTests
{
[Test]
@ -15,191 +16,143 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements @@ -15,191 +16,143 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("int a = 5;");
Assert.AreEqual(1, lvd.Variables.Count());
/*Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("System.Int32", type.Type);
Assert.AreEqual(5, ((PrimitiveExpression)lvd.Variables[0].Initializer).Value);*/ throw new NotImplementedException();
Assert.AreEqual("a", lvd.Variables.First ().Name);
var type = lvd.Type;
Assert.AreEqual("int", type.ToString ());
Assert.AreEqual(5, ((PrimitiveExpression)lvd.Variables.First ().Initializer).Value);
}
/* TODO port unit tests
[Test]
public void VoidPointerVariableDeclarationTest()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("void *a;");
Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("System.Void", type.Type);
Assert.AreEqual(1, type.PointerNestingLevel);
Assert.IsTrue(new VariableDeclarationStatement(new PrimitiveType("void").MakePointerType(), "a").IsMatch(lvd));
}
[Test]
public void ComplexGenericVariableDeclarationStatementTest()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("Generic<Namespace.Printable, G<Printable[]> > where = new Generic<Namespace.Printable, G<Printable[]>>();");
Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("where", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("Generic", type.Type);
Assert.AreEqual(2, type.GenericTypes.Count);
Assert.AreEqual("Namespace.Printable", type.GenericTypes[0].Type);
Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count);
Assert.AreEqual("G", type.GenericTypes[1].Type);
Assert.AreEqual(1, type.GenericTypes[1].GenericTypes.Count);
Assert.AreEqual("Printable", type.GenericTypes[1].GenericTypes[0].Type);
// TODO: Check initializer
AstType type = new SimpleType("Generic") {
TypeArguments = {
new MemberType { Target = new SimpleType("Namespace"), MemberName = "Printable" },
new SimpleType("G") { TypeArguments = { new SimpleType("Printable").MakeArrayType() } }
}};
Assert.IsTrue(new VariableDeclarationStatement(type, "where", new ObjectCreateExpression { Type = type.Clone() }).IsMatch(lvd));
}
[Test]
public void NestedGenericVariableDeclarationStatementTest()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("MyType<string>.InnerClass<int>.InnerInnerClass a;");
Assert.AreEqual(1, lvd.Variables.Count);
InnerClassTypeReference ic = (InnerClassTypeReference)lvd.GetTypeForVariable(0);
Assert.AreEqual("InnerInnerClass", ic.Type);
Assert.AreEqual(0, ic.GenericTypes.Count);
ic = (InnerClassTypeReference)ic.BaseType;
Assert.AreEqual("InnerClass", ic.Type);
Assert.AreEqual(1, ic.GenericTypes.Count);
Assert.AreEqual("System.Int32", ic.GenericTypes[0].Type);
Assert.AreEqual("MyType", ic.BaseType.Type);
Assert.AreEqual(1, ic.BaseType.GenericTypes.Count);
Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type);
AstType type = new MemberType {
Target = new MemberType {
Target = new SimpleType("MyType") { TypeArguments = { new PrimitiveType("string") } },
MemberName = "InnerClass",
TypeArguments = { new PrimitiveType("int") }
},
MemberName = "InnerInnerClass"
};
Assert.IsTrue(new VariableDeclarationStatement(type, "a").IsMatch(lvd));
}
[Test]
public void GenericWithArrayVariableDeclarationStatementTest1()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("G<int>[] a;");
Assert.AreEqual(1, lvd.Variables.Count);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count);
Assert.IsFalse(type.GenericTypes[0].IsArrayType);
Assert.AreEqual(new int[] {0}, type.RankSpecifier);
AstType type = new SimpleType("G") {
TypeArguments = { new PrimitiveType("int") }
}.MakeArrayType();
Assert.IsTrue(new VariableDeclarationStatement(type, "a").IsMatch(lvd));
}
[Test]
public void GenericWithArrayVariableDeclarationStatementTest2()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("G<int[]> a;");
Assert.AreEqual(1, lvd.Variables.Count);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count);
Assert.IsFalse(type.IsArrayType);
Assert.AreEqual(new int[] {0}, type.GenericTypes[0].RankSpecifier);
AstType type = new SimpleType("G") {
TypeArguments = { new PrimitiveType("int").MakeArrayType() }
};
Assert.IsTrue(new VariableDeclarationStatement(type, "a").IsMatch(lvd));
}
[Test]
public void GenericVariableDeclarationStatementTest2()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("G<G<int> > a;");
Assert.AreEqual(1, lvd.Variables.Count);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("G", type.GenericTypes[0].Type);
Assert.AreEqual(1, type.GenericTypes[0].GenericTypes.Count);
Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].Type);
AstType type = new SimpleType("G") {
TypeArguments = {
new SimpleType("G") { TypeArguments = { new PrimitiveType("int") } }
}
};
Assert.IsTrue(new VariableDeclarationStatement(type, "a").IsMatch(lvd));
}
[Test]
public void GenericVariableDeclarationStatementTest2WithoutSpace()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("G<G<int>> a;");
Assert.AreEqual(1, lvd.Variables.Count);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("G", type.GenericTypes[0].Type);
Assert.AreEqual(1, type.GenericTypes[0].GenericTypes.Count);
Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].Type);
AstType type = new SimpleType("G") {
TypeArguments = {
new SimpleType("G") { TypeArguments = { new PrimitiveType("int") } }
}
};
Assert.IsTrue(new VariableDeclarationStatement(type, "a").IsMatch(lvd));
}
[Test]
public void GenericVariableDeclarationStatementTest()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("G<int> a;");
Assert.AreEqual(1, lvd.Variables.Count);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("G", type.Type);
Assert.AreEqual(1, type.GenericTypes.Count);
Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
AstType type = new SimpleType("G") {
TypeArguments = { new PrimitiveType("int") }
};
Assert.IsTrue(new VariableDeclarationStatement(type, "a").IsMatch(lvd));
}
[Test]
public void SimpleVariableDeclarationStatementTest()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("MyVar var = new MyVar();");
Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("var", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("MyVar", type.Type);
// TODO: Check initializer
Assert.IsTrue(new VariableDeclarationStatement(new SimpleType("MyVar"), "var", new ObjectCreateExpression { Type = new SimpleType("MyVar") }).IsMatch(lvd));
}
[Test]
public void SimpleVariableDeclarationStatementTest1()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("yield yield = new yield();");
Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("yield", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("yield", type.Type);
// TODO: Check initializer
Assert.IsTrue(new VariableDeclarationStatement(new SimpleType("yield"), "yield", new ObjectCreateExpression { Type = new SimpleType("yield") }).IsMatch(lvd));
}
[Test]
public void NullableVariableDeclarationStatementTest1()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("int? a;");
Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("System.Nullable", type.Type);
Assert.AreEqual("System.Int32", type.GenericTypes[0].Type);
Assert.IsTrue(new VariableDeclarationStatement(new PrimitiveType("int").MakeNullableType(), "a").IsMatch(lvd));
}
[Test]
public void NullableVariableDeclarationStatementTest2()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("DateTime? a;");
Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("System.Nullable", type.Type);
Assert.AreEqual("DateTime", type.GenericTypes[0].Type);
Assert.IsTrue(new VariableDeclarationStatement(new SimpleType("DateTime").MakeNullableType(), "a").IsMatch(lvd));
}
[Test]
[Test, Ignore("The parser creates nested ComposedTypes while MakeArrayType() adds the specifier to the existing ComposedType")]
public void NullableVariableDeclarationStatementTest3()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("DateTime?[] a;");
Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.IsTrue(type.IsArrayType);
Assert.AreEqual("System.Nullable", type.Type);
Assert.AreEqual("DateTime", type.GenericTypes[0].Type);
Assert.IsTrue(new VariableDeclarationStatement(new SimpleType("DateTime").MakeNullableType().MakeArrayType(), "a").IsMatch(lvd));
}
[Test]
public void NullableVariableDeclarationStatementTest4()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("SomeStruct<int?>? a;");
Assert.AreEqual(1, lvd.Variables.Count);
Assert.AreEqual("a", ((VariableDeclaration)lvd.Variables[0]).Name);
TypeReference type = lvd.GetTypeForVariable(0);
Assert.AreEqual("System.Nullable", type.Type);
Assert.AreEqual("SomeStruct", type.GenericTypes[0].Type);
Assert.AreEqual("System.Nullable", type.GenericTypes[0].GenericTypes[0].Type);
Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].GenericTypes[0].Type);
AstType type = new SimpleType("SomeStruct") {
TypeArguments = { new PrimitiveType("int").MakeNullableType() }
}.MakeNullableType();
Assert.IsTrue(new VariableDeclarationStatement(type, "a").IsMatch(lvd));
}
[Test]
@ -216,11 +169,39 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements @@ -216,11 +169,39 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.Statements
public void PositionTestWithModifier()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("\nconst double w = 7;");
Assert.AreEqual(Modifiers.Const, lvd.Modifier);
Assert.AreEqual(Modifiers.Const, lvd.Modifiers);
Assert.AreEqual(2, lvd.StartLocation.Line);
Assert.AreEqual(1, lvd.StartLocation.Column);
Assert.AreEqual(2, lvd.EndLocation.Line);
Assert.AreEqual(20, lvd.EndLocation.Column);
}*/
}
[Test, Ignore("Nested arrays are broken in the parser")]
public void NestedArray()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("DateTime[,][] a;");
Assert.IsTrue(new VariableDeclarationStatement(new SimpleType("DateTime").MakeArrayType(1).MakeArrayType(2), "a").IsMatch(lvd));
}
[Test, Ignore("Nested pointers are broken in the parser")]
public void NestedPointers()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("DateTime*** a;");
Assert.IsTrue(new VariableDeclarationStatement(new SimpleType("DateTime").MakePointerType().MakePointerType().MakePointerType(), "a").IsMatch(lvd));
}
[Test, Ignore("The parser creates nested ComposedTypes while MakeArrayType() adds the specifier to the existing ComposedType")]
public void ArrayOfPointers()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("DateTime*[] a;");
Assert.IsTrue(new VariableDeclarationStatement(new SimpleType("DateTime").MakePointerType().MakeArrayType(), "a").IsMatch(lvd));
}
[Test, Ignore("The parser creates nested ComposedTypes while MakeArrayType() adds the specifier to the existing ComposedType")]
public void ArrayOfNullables()
{
VariableDeclarationStatement lvd = ParseUtilCSharp.ParseStatement<VariableDeclarationStatement>("DateTime?[] a;");
Assert.IsTrue(new VariableDeclarationStatement(new SimpleType("DateTime").MakeNullableType().MakeArrayType(), "a").IsMatch(lvd));
}
}
}

4
ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/ConstructorDeclarationTests.cs

@ -17,7 +17,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -17,7 +17,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
Assert.IsTrue(cd.Initializer.IsNull);
}
[Test, Ignore("Constructor initializer is broken")]
[Test]
public void ConstructorDeclarationTest2()
{
ConstructorDeclaration cd = ParseUtilCSharp.ParseTypeMember<ConstructorDeclaration>("MyClass() : this(5) {}");
@ -25,7 +25,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -25,7 +25,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
Assert.AreEqual(1, cd.Initializer.Arguments.Count());
}
[Test, Ignore("Constructor initializer is broken")]
[Test]
public void ConstructorDeclarationTest3()
{
ConstructorDeclaration cd = ParseUtilCSharp.ParseTypeMember<ConstructorDeclaration>("MyClass() : base(1, 2, 3) {}");

4
ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/EventDeclarationTests.cs

@ -6,7 +6,7 @@ using NUnit.Framework; @@ -6,7 +6,7 @@ using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
{
[TestFixture, Ignore("events are broken")]
[TestFixture]
public class EventDeclarationTests
{
[Test]
@ -38,7 +38,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -38,7 +38,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
},
new VariableInitializer {
Name = "B",
Initializer = new AnonymousMethodExpression()
Initializer = new AnonymousMethodExpression() { Body = new BlockStatement ()}
}
}});
}

15
ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/FieldDeclarationTests.cs

@ -9,7 +9,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -9,7 +9,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
[TestFixture]
public class FieldDeclarationTests
{
[Test, Ignore("multidimensional array rank incorrect?")]
[Test]
public void SimpleFieldDeclarationTest()
{
ParseUtilCSharp.AssertTypeMember(
@ -56,12 +56,21 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -56,12 +56,21 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
}});
}
[Test, Ignore("How do we represent fixed-size fields in the AST?")]
[Test]
public void FieldWithFixedSize()
{
ParseUtilCSharp.AssertTypeMember(
"public unsafe fixed int Field[100];",
new FieldDeclaration());
new FixedFieldDeclaration() {
Modifiers = Modifiers.Public | Modifiers.Unsafe,
ReturnType = new PrimitiveType("int"),
Variables = {
new FixedVariableInitializer {
Name = "Field",
CountExpression = new PrimitiveExpression(100)
}
}
});
}
}
}

4
ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/IndexerDeclarationTests.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -22,7 +22,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
Assert.AreEqual(Modifiers.Protected, id.Setter.Modifiers);
}
[Test, Ignore("explicit interface implementation not yet supported")]
[Test]
public void IndexerImplementingInterfaceTest()
{
IndexerDeclaration id = ParseUtilCSharp.ParseTypeMember<IndexerDeclaration>("int MyInterface.this[int a, string b] { get { } set { } }");
@ -33,7 +33,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -33,7 +33,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
Assert.AreEqual("MyInterface", ((SimpleType)id.PrivateImplementationType).Identifier);
}
[Test, Ignore("explicit interface implementation not yet supported")]
[Test]
public void IndexerImplementingGenericInterfaceTest()
{
ParseUtilCSharp.AssertTypeMember(

21
ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/MethodDeclarationTests.cs

@ -8,7 +8,7 @@ using NUnit.Framework; @@ -8,7 +8,7 @@ using NUnit.Framework;
namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
{
[TestFixture, Ignore("Generics not yet implemented")]
[TestFixture]
public class MethodDeclarationTests
{
[Test]
@ -89,7 +89,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -89,7 +89,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
public void MethodWithUnnamedParameterDeclarationTest()
{
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>("void MyMethod(int) {} ", true);
Assert.AreEqual("System.Void", md.ReturnType);
Assert.AreEqual("void", md.ReturnType.ToString ());
Assert.AreEqual(1, md.Parameters.Count());
Assert.AreEqual("int", ((PrimitiveType)md.Parameters.Single().Type).Keyword);
}
@ -202,6 +202,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -202,6 +202,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
",
new TypeDeclaration {
ClassType = ClassType.Interface,
Name = "MyInterface",
BaseTypes = { new SimpleType("IDisposable") },
Members = {
new MethodDeclaration {
@ -214,7 +215,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -214,7 +215,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
[Test]
public void MethodImplementingInterfaceTest()
{
ParseUtilCSharp.AssertGlobal(
ParseUtilCSharp.AssertTypeMember(
"int MyInterface.MyMethod() {} ",
new MethodDeclaration {
ReturnType = new PrimitiveType("int"),
@ -227,7 +228,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -227,7 +228,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
[Test]
public void MethodImplementingGenericInterfaceTest()
{
ParseUtilCSharp.AssertGlobal(
ParseUtilCSharp.AssertTypeMember(
"int MyInterface<string>.MyMethod() {} ",
new MethodDeclaration {
ReturnType = new PrimitiveType("int"),
@ -240,7 +241,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -240,7 +241,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
[Test]
public void VoidMethodImplementingInterfaceTest()
{
ParseUtilCSharp.AssertGlobal(
ParseUtilCSharp.AssertTypeMember (
"void MyInterface.MyMethod() {} ",
new MethodDeclaration {
ReturnType = new PrimitiveType("void"),
@ -253,11 +254,11 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -253,11 +254,11 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
[Test]
public void VoidMethodImplementingGenericInterfaceTest()
{
ParseUtilCSharp.AssertGlobal(
ParseUtilCSharp.AssertTypeMember (
"void MyInterface<string>.MyMethod() {} ",
new MethodDeclaration {
ReturnType = new PrimitiveType("void"),
PrivateImplementationType = new SimpleType("MyInterface"),
PrivateImplementationType = new SimpleType("MyInterface") { TypeArguments = { new PrimitiveType("string") } },
Name = "MyMethod",
Body = new BlockStatement()
});
@ -305,15 +306,15 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -305,15 +306,15 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
public void MethodWithEmptyAssignmentErrorInBody()
{
MethodDeclaration md = ParseUtilCSharp.ParseTypeMember<MethodDeclaration>(
"void A\n" +
"void A ()\n" +
"{\n" +
"int a = 3;\n" +
" = 4;\n" +
"}", true // expect errors
);
Assert.AreEqual("A", md.Name);
Assert.AreEqual(new AstLocation(1, 2), md.Body.StartLocation);
Assert.AreEqual(new AstLocation(2, 5), md.Body.EndLocation);
Assert.AreEqual(new AstLocation(2, 1), md.Body.StartLocation);
Assert.AreEqual(new AstLocation(5, 2), md.Body.EndLocation);
}
[Test]

7
ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/PropertyDeclarationTests.cs

@ -5,6 +5,7 @@ using System; @@ -5,6 +5,7 @@ using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using ICSharpCode.NRefactory.PatternMatching;
namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
{
@ -66,7 +67,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -66,7 +67,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
Assert.AreEqual(new AstLocation(4, code.IndexOf("}\n\t}") + 1 - line4Pos + 1), pd.Setter.Body.EndLocation);
}
[Test, Ignore("explicit interface implementation not yet implemented")]
[Test]
public void PropertyImplementingInterfaceTest()
{
PropertyDeclaration pd = ParseUtilCSharp.ParseTypeMember<PropertyDeclaration>("int MyInterface.MyProperty { get {} } ");
@ -77,7 +78,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -77,7 +78,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
Assert.AreEqual("MyInterface", ((SimpleType)pd.PrivateImplementationType).Identifier);
}
[Test, Ignore("explicit interface implementation not yet implemented")]
[Test]
public void PropertyImplementingGenericInterfaceTest()
{
PropertyDeclaration pd = ParseUtilCSharp.ParseTypeMember<PropertyDeclaration>("int MyInterface<string>.MyProperty { get {} } ");
@ -85,7 +86,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -85,7 +86,7 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
Assert.IsFalse(pd.Getter.IsNull);
Assert.IsTrue(pd.Setter.IsNull);
Assert.IsNotNull(new SimpleType { Identifier = "MyInterface", TypeArguments = { new PrimitiveType("string") } }.Match(pd.PrivateImplementationType));
Assert.IsTrue(new SimpleType { Identifier = "MyInterface", TypeArguments = { new PrimitiveType("string") } }.IsMatch(pd.PrivateImplementationType));
}
}
}

14
ICSharpCode.NRefactory.Tests/CSharp/Resolver/LambdaTests.cs

@ -274,5 +274,19 @@ class TestClass { @@ -274,5 +274,19 @@ class TestClass {
var lrr = Resolve<LocalResolveResult>(program);
Assert.AreEqual("System.Int32", lrr.Type.ReflectionName);
}
/* TODO write test for this
class A
{
static void Foo(string x, Action<Action> y) { Console.WriteLine(1); }
static void Foo(object x, Func<Func<int>, int> y) { Console.WriteLine(2); }
static void Main()
{
Foo(null, x => x()); // Prints 1
Foo(null, x => (x())); // Prints 2
}
}
*/
}
}

8
ICSharpCode.NRefactory.Tests/CSharp/Resolver/OverloadResolutionTests.cs

@ -138,7 +138,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -138,7 +138,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
// static void Foo<T>(T? ignored = default(T?)) where T : struct
var m1 = MakeMethod();
m1.TypeParameters.Add(new DefaultTypeParameter(m1, 0, "T") { HasValueTypeConstraint = true });
m1.TypeParameters.Add(new DefaultTypeParameter(EntityType.Method, 0, "T") { HasValueTypeConstraint = true });
m1.Parameters.Add(MakeOptionalParameter(
NullableType.Create(m1.TypeParameters[0], context),
"ignored"
@ -146,12 +146,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -146,12 +146,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
// class ClassConstraint<T> where T : class {}
DefaultTypeDefinition classConstraint = new DefaultTypeDefinition(dummyClass, "ClassConstraint");
classConstraint.TypeParameters.Add(new DefaultTypeParameter(classConstraint, 0, "T") { HasReferenceTypeConstraint = true });
classConstraint.TypeParameters.Add(new DefaultTypeParameter(EntityType.TypeDefinition, 0, "T") { HasReferenceTypeConstraint = true });
// static void Foo<T>(ClassConstraint<T> ignored = default(ClassConstraint<T>))
// where T : class
var m2 = MakeMethod();
m2.TypeParameters.Add(new DefaultTypeParameter(m2, 0, "T") { HasReferenceTypeConstraint = true });
m2.TypeParameters.Add(new DefaultTypeParameter(EntityType.Method, 0, "T") { HasReferenceTypeConstraint = true });
m2.Parameters.Add(MakeOptionalParameter(
new ParameterizedType(classConstraint, new[] { m2.TypeParameters[0] }),
"ignored"
@ -159,7 +159,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -159,7 +159,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
// static void Foo<T>()
var m3 = MakeMethod();
m3.TypeParameters.Add(new DefaultTypeParameter(m3, 0, "T"));
m3.TypeParameters.Add(new DefaultTypeParameter(EntityType.Method, 0, "T"));
// Call: Foo<int>();
OverloadResolution o;

14
ICSharpCode.NRefactory.Tests/FormattingTests/TestBlankLineFormatting.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestBlankLinesAfterUsings ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.BlankLinesAfterUsings = 2;
var adapter = Test (policy, @"using System;
@ -65,7 +65,7 @@ namespace Test @@ -65,7 +65,7 @@ namespace Test
[Test()]
public void TestBlankLinesBeforeUsings ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.BlankLinesAfterUsings = 0;
policy.BlankLinesBeforeUsings = 2;
@ -94,7 +94,7 @@ namespace Test @@ -94,7 +94,7 @@ namespace Test
[Test()]
public void TestBlankLinesBeforeFirstDeclaration ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.BlankLinesBeforeFirstDeclaration = 2;
var adapter = Test (policy, @"namespace Test
@ -125,7 +125,7 @@ namespace Test @@ -125,7 +125,7 @@ namespace Test
[Test()]
public void TestBlankLinesBetweenTypes ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.BlankLinesBetweenTypes = 1;
var adapter = Test (policy, @"namespace Test
@ -173,7 +173,7 @@ namespace Test @@ -173,7 +173,7 @@ namespace Test
[Test()]
public void TestBlankLinesBetweenFields ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.BlankLinesBetweenFields = 1;
var adapter = Test (policy, @"class Test
@ -203,7 +203,7 @@ namespace Test @@ -203,7 +203,7 @@ namespace Test
[Test()]
public void TestBlankLinesBetweenEventFields ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.BlankLinesBetweenEventFields = 1;
var adapter = Test (policy, @"class Test
@ -234,7 +234,7 @@ namespace Test @@ -234,7 +234,7 @@ namespace Test
[Test()]
public void TestBlankLinesBetweenMembers ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.BlankLinesBetweenMembers = 1;
var adapter = Test (policy,@"class Test

32
ICSharpCode.NRefactory.Tests/FormattingTests/TestBraceStlye.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestNamespaceBraceStyle ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.NamespaceBraceStyle = BraceStyle.EndOfLine;
policy.ClassBraceStyle = BraceStyle.DoNotChange;
@ -67,7 +67,7 @@ namespace B { @@ -67,7 +67,7 @@ namespace B {
[Test()]
public void TestClassBraceStlye ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy,
@ -79,7 +79,7 @@ namespace B { @@ -79,7 +79,7 @@ namespace B {
[Test()]
public void TestStructBraceStyle ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StructBraceStyle = BraceStyle.NextLine;
Test (policy,
@ -92,7 +92,7 @@ namespace B { @@ -92,7 +92,7 @@ namespace B {
[Test()]
public void TestInterfaceBraceStyle ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.InterfaceBraceStyle = BraceStyle.NextLine;
Test (policy,
@ -105,7 +105,7 @@ namespace B { @@ -105,7 +105,7 @@ namespace B {
[Test()]
public void TestEnumBraceStyle ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.EnumBraceStyle = BraceStyle.NextLineShifted;
Test (policy, @"enum Test {
@ -120,7 +120,7 @@ namespace B { @@ -120,7 +120,7 @@ namespace B {
[Test()]
public void TestMethodBraceStlye ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.MethodBraceStyle = BraceStyle.NextLine;
Test (policy, @"class Test
@ -138,7 +138,7 @@ namespace B { @@ -138,7 +138,7 @@ namespace B {
[Test()]
public void TestConstructorBraceStyle ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ConstructorBraceStyle = BraceStyle.NextLine;
Test (policy, @"class Test
@ -156,7 +156,7 @@ namespace B { @@ -156,7 +156,7 @@ namespace B {
[Test()]
public void TestDestructorBraceStyle ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.DestructorBraceStyle = BraceStyle.NextLine;
Test (policy, @"class Test
@ -174,7 +174,7 @@ namespace B { @@ -174,7 +174,7 @@ namespace B {
[Test()]
public void TestPropertyBraceStyle ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PropertyBraceStyle = BraceStyle.NextLine;
Test (policy, @"class Test
@ -197,7 +197,7 @@ namespace B { @@ -197,7 +197,7 @@ namespace B {
[Test()]
public void TestPropertyGetBraceStyle ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PropertyGetBraceStyle = BraceStyle.NextLine;
Test (policy, @"class Test
@ -225,7 +225,7 @@ namespace B { @@ -225,7 +225,7 @@ namespace B {
public void TestAllowPropertyGetBlockInline ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PropertyBraceStyle = BraceStyle.DoNotChange;
policy.AllowPropertyGetBlockInline = true;
policy.AllowPropertySetBlockInline = false;
@ -265,7 +265,7 @@ namespace B { @@ -265,7 +265,7 @@ namespace B {
[Test()]
public void TestAllowPropertySetBlockInline ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PropertyBraceStyle = BraceStyle.DoNotChange;
policy.AllowPropertyGetBlockInline = false;
policy.AllowPropertySetBlockInline = true;
@ -305,7 +305,7 @@ namespace B { @@ -305,7 +305,7 @@ namespace B {
[Test()]
public void TestPropertySetBraceStyle ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PropertySetBraceStyle = BraceStyle.NextLine;
Test (policy, @"class Test
@ -332,7 +332,7 @@ namespace B { @@ -332,7 +332,7 @@ namespace B {
[Test()]
public void TestEventBraceStyle ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.EventBraceStyle = BraceStyle.NextLine;
policy.EventAddBraceStyle = BraceStyle.NextLine;
policy.EventRemoveBraceStyle = BraceStyle.NextLine;
@ -363,7 +363,7 @@ namespace B { @@ -363,7 +363,7 @@ namespace B {
[Test()]
public void TestAllowEventAddBlockInline ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.AllowEventAddBlockInline = true;
policy.AllowEventRemoveBlockInline = false;
@ -388,7 +388,7 @@ namespace B { @@ -388,7 +388,7 @@ namespace B {
[Test()]
public void TestAllowEventRemoveBlockInline ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.AllowEventAddBlockInline = false;
policy.AllowEventRemoveBlockInline = true;

16
ICSharpCode.NRefactory.Tests/FormattingTests/TestFormattingBugs.cs

@ -40,7 +40,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -40,7 +40,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestBug325187 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PlaceElseOnNewLine = true;
TestStatementFormatting (policy,
@ -62,7 +62,7 @@ Console.WriteLine (""Bad indent"");", @@ -62,7 +62,7 @@ Console.WriteLine (""Bad indent"");",
[Test()]
public void TestBug415469 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
TestStatementFormatting (policy,
@"switch (condition) {
@ -86,7 +86,7 @@ case CONDITION2: @@ -86,7 +86,7 @@ case CONDITION2:
[Test()]
public void TestBug540043 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
TestStatementFormatting (policy,
@"using (IDisposable a = null)
@ -105,7 +105,7 @@ using (IDisposable b = null) { @@ -105,7 +105,7 @@ using (IDisposable b = null) {
[Test()]
public void TestBug655635 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
TestStatementFormatting (policy,
@"try {
@ -121,7 +121,7 @@ using (IDisposable b = null) { @@ -121,7 +121,7 @@ using (IDisposable b = null) {
}");
}
void TestStatementFormatting (CSharpFormattingPolicy policy, string input, string expectedOutput)
void TestStatementFormatting (CSharpFormattingOptions policy, string input, string expectedOutput)
{
var result = GetResult (policy, @"class Test
{
@ -143,7 +143,7 @@ using (IDisposable b = null) { @@ -143,7 +143,7 @@ using (IDisposable b = null) {
[Test()]
public void TestBug659675 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
TestStatementFormatting (policy, "@string=@int;", "@string = @int;");
}
@ -153,7 +153,7 @@ using (IDisposable b = null) { @@ -153,7 +153,7 @@ using (IDisposable b = null) {
[Test()]
public void TestBug670213 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.MethodBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test
@ -176,7 +176,7 @@ using (IDisposable b = null) { @@ -176,7 +176,7 @@ using (IDisposable b = null) {
[Test()]
public void TestBug677261 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ConstructorBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test

168
ICSharpCode.NRefactory.Tests/FormattingTests/TestSpacingVisitor.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestFieldSpacesBeforeComma1 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
policy.SpaceBeforeFieldDeclarationComma = false;
policy.SpaceAfterFieldDeclarationComma = false;
@ -53,7 +53,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -53,7 +53,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestFieldSpacesBeforeComma2 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
policy.SpaceBeforeFieldDeclarationComma = true;
policy.SpaceAfterFieldDeclarationComma = true;
@ -69,7 +69,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -69,7 +69,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestFixedFieldSpacesBeforeComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
policy.SpaceAfterFieldDeclarationComma = true;
policy.SpaceBeforeFieldDeclarationComma = true;
@ -85,7 +85,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -85,7 +85,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestConstFieldSpacesBeforeComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
policy.SpaceAfterFieldDeclarationComma = false;
policy.SpaceBeforeFieldDeclarationComma = false;
@ -101,7 +101,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -101,7 +101,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestBeforeMethodDeclarationParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeMethodDeclarationParentheses = true;
Test (policy, @"public abstract class Test
@ -117,7 +117,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -117,7 +117,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestBeforeConstructorDeclarationParenthesesDestructorCase ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeConstructorDeclarationParentheses = true;
Test (policy, @"class Test
@ -134,7 +134,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -134,7 +134,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
}");
}
static void TestBinaryOperator (CSharpFormattingPolicy policy, string op)
static void TestBinaryOperator (CSharpFormattingOptions policy, string op)
{
var result = GetResult (policy, "class Test { void TestMe () { result = left" + op + "right; } }");
@ -148,7 +148,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -148,7 +148,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestSpacesAroundMultiplicativeOperator ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAroundMultiplicativeOperator = true;
TestBinaryOperator (policy, "*");
@ -158,7 +158,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -158,7 +158,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestSpacesAroundShiftOperator ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAroundShiftOperator = true;
TestBinaryOperator (policy, "<<");
TestBinaryOperator (policy, ">>");
@ -167,7 +167,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -167,7 +167,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestSpacesAroundAdditiveOperator ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAroundAdditiveOperator = true;
TestBinaryOperator (policy, "+");
@ -177,7 +177,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -177,7 +177,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestSpacesAroundBitwiseOperator ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAroundBitwiseOperator = true;
TestBinaryOperator (policy, "&");
@ -188,7 +188,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -188,7 +188,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestSpacesAroundRelationalOperator ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAroundRelationalOperator = true;
TestBinaryOperator (policy, "<");
@ -200,7 +200,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -200,7 +200,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestSpacesAroundEqualityOperator ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAroundEqualityOperator = true;
TestBinaryOperator (policy, "==");
@ -210,7 +210,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -210,7 +210,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestSpacesAroundLogicalOperator ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAroundLogicalOperator = true;
TestBinaryOperator (policy, "&&");
@ -220,7 +220,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -220,7 +220,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestConditionalOperator ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeConditionalOperatorCondition = true;
policy.SpaceAfterConditionalOperatorCondition = true;
policy.SpaceBeforeConditionalOperatorSeparator = true;
@ -256,7 +256,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -256,7 +256,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestBeforeMethodCallParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeMethodCallParentheses = true;
var result = GetResult (policy, @"class Test {
@ -288,7 +288,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -288,7 +288,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestWithinMethodCallParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceWithinMethodCallParentheses = true;
var result = GetResult (policy, @"class Test {
@ -318,7 +318,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -318,7 +318,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestBeforeIfParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeIfParentheses = true;
var result = GetResult (policy, @"class Test {
@ -335,7 +335,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -335,7 +335,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestWithinIfParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinIfParentheses = true;
var result = GetResult (policy, @"class Test {
@ -352,7 +352,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -352,7 +352,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestBeforeWhileParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeWhileParentheses = true;
var result = GetResult (policy, @"class Test {
@ -369,7 +369,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -369,7 +369,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestWithinWhileParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinWhileParentheses = true;
var result = GetResult (policy, @"class Test {
@ -387,7 +387,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -387,7 +387,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestBeforeForParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeForParentheses = true;
var result = GetResult (policy, @"class Test {
@ -404,7 +404,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -404,7 +404,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestWithinForParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinForParentheses = true;
var result = GetResult (policy, @"class Test {
@ -421,7 +421,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -421,7 +421,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestBeforeForeachParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeForeachParentheses = true;
var result = GetResult (policy, @"class Test {
@ -438,7 +438,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -438,7 +438,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestWithinForeachParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinForeachParentheses = true;
var result = GetResult (policy, @"class Test {
@ -455,7 +455,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -455,7 +455,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestBeforeCatchParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeCatchParentheses = true;
var result = GetResult (policy, @"class Test {
@ -472,7 +472,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -472,7 +472,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestWithinCatchParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinCatchParentheses = true;
var result = GetResult (policy, @"class Test {
@ -489,7 +489,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -489,7 +489,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestBeforeLockParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeLockParentheses = true;
var result = GetResult (policy, @"class Test {
@ -506,7 +506,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -506,7 +506,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestWithinLockParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinLockParentheses = true;
var result = GetResult (policy, @"class Test {
@ -523,7 +523,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -523,7 +523,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestSpacesAfterForSemicolon ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAfterForSemicolon = true;
var result = GetResult (policy, @"class Test {
@ -541,7 +541,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -541,7 +541,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestSpacesBeforeForSemicolon ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeForSemicolon = true;
policy.SpaceAfterForSemicolon = false;
@ -560,7 +560,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -560,7 +560,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestSpacesAfterTypecast ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAfterTypecast = true;
var result = GetResult (policy, @"class Test {
@ -578,7 +578,7 @@ return (Test)null; @@ -578,7 +578,7 @@ return (Test)null;
[Test()]
public void TestBeforeUsingParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeUsingParentheses = true;
var result = GetResult (policy, @"class Test {
@ -595,7 +595,7 @@ return (Test)null; @@ -595,7 +595,7 @@ return (Test)null;
[Test()]
public void TestWithinUsingParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinUsingParentheses = true;
var result = GetResult (policy, @"class Test {
@ -609,7 +609,7 @@ return (Test)null; @@ -609,7 +609,7 @@ return (Test)null;
Assert.AreEqual (@"( a )", result.GetTextAt (i1, i2 - i1));
}
static void TestAssignmentOperator (CSharpFormattingPolicy policy, string op)
static void TestAssignmentOperator (CSharpFormattingOptions policy, string op)
{
var result = GetResult (policy, "class Test { void TestMe () { left" + op + "right; } }");
@ -623,7 +623,7 @@ return (Test)null; @@ -623,7 +623,7 @@ return (Test)null;
[Test()]
public void TestAroundAssignmentSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAroundAssignment = true;
TestAssignmentOperator (policy, "=");
@ -642,7 +642,7 @@ return (Test)null; @@ -642,7 +642,7 @@ return (Test)null;
[Test()]
public void TestAroundAssignmentSpaceInDeclarations ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAroundAssignment = true;
var result = GetResult (policy, @"class Test {
void TestMe ()
@ -659,7 +659,7 @@ return (Test)null; @@ -659,7 +659,7 @@ return (Test)null;
[Test()]
public void TestBeforeSwitchParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeSwitchParentheses = true;
var result = GetResult (policy, @"class Test {
@ -676,7 +676,7 @@ return (Test)null; @@ -676,7 +676,7 @@ return (Test)null;
[Test()]
public void TestWithinSwitchParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinSwitchParentheses = true;
var result = GetResult (policy, @"class Test {
@ -693,7 +693,7 @@ return (Test)null; @@ -693,7 +693,7 @@ return (Test)null;
[Test()]
public void TestWithinParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinParentheses = true;
var result = GetResult (policy, @"class Test {
@ -710,7 +710,7 @@ return (Test)null; @@ -710,7 +710,7 @@ return (Test)null;
[Test()]
public void TestWithinMethodDeclarationParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceWithinMethodDeclarationParentheses = true;
var result = GetResult (policy, @"class Test {
@ -726,7 +726,7 @@ return (Test)null; @@ -726,7 +726,7 @@ return (Test)null;
[Test()]
public void TestWithinCastParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinCastParentheses = true;
var result = GetResult (policy, @"class Test {
@ -743,7 +743,7 @@ return (Test)null; @@ -743,7 +743,7 @@ return (Test)null;
[Test()]
public void TestWithinSizeOfParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinSizeOfParentheses = true;
var result = GetResult (policy, @"class Test {
@ -760,7 +760,7 @@ return (Test)null; @@ -760,7 +760,7 @@ return (Test)null;
[Test()]
public void TestBeforeSizeOfParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeSizeOfParentheses = true;
var result = GetResult (policy, @"class Test {
@ -777,7 +777,7 @@ return (Test)null; @@ -777,7 +777,7 @@ return (Test)null;
[Test()]
public void TestWithinTypeOfParenthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinTypeOfParentheses = true;
var result = GetResult (policy, @"class Test {
@ -794,7 +794,7 @@ return (Test)null; @@ -794,7 +794,7 @@ return (Test)null;
[Test()]
public void TestBeforeTypeOfParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeTypeOfParentheses = true;
var result = GetResult (policy, @"class Test {
@ -812,7 +812,7 @@ return (Test)null; @@ -812,7 +812,7 @@ return (Test)null;
[Test()]
public void TestWithinCheckedExpressionParanthesesSpace ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinCheckedExpressionParantheses = true;
var result = GetResult (policy, @"class Test {
@ -841,7 +841,7 @@ return (Test)null; @@ -841,7 +841,7 @@ return (Test)null;
[Test()]
public void TestSpaceBeforeNewParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeNewParentheses = true;
var result = GetResult (policy, @"class Test {
@ -858,7 +858,7 @@ return (Test)null; @@ -858,7 +858,7 @@ return (Test)null;
[Test()]
public void TestWithinNewParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinNewParentheses = true;
var result = GetResult (policy, @"class Test {
@ -875,7 +875,7 @@ return (Test)null; @@ -875,7 +875,7 @@ return (Test)null;
[Test()]
public void TestBetweenEmptyNewParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesBetweenEmptyNewParentheses = true;
var result = GetResult (policy, @"class Test {
@ -892,7 +892,7 @@ return (Test)null; @@ -892,7 +892,7 @@ return (Test)null;
[Test()]
public void TestBeforeNewParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeNewParameterComma = true;
policy.SpaceAfterNewParameterComma = false;
@ -910,7 +910,7 @@ return (Test)null; @@ -910,7 +910,7 @@ return (Test)null;
[Test()]
public void TestAfterNewParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAfterNewParameterComma = true;
var result = GetResult (policy, @"class Test {
@ -927,7 +927,7 @@ return (Test)null; @@ -927,7 +927,7 @@ return (Test)null;
[Test()]
public void TestFieldDeclarationComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeFieldDeclarationComma = false;
policy.SpaceAfterFieldDeclarationComma = true;
@ -955,7 +955,7 @@ return (Test)null; @@ -955,7 +955,7 @@ return (Test)null;
[Test()]
public void TestBeforeMethodDeclarationParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeMethodDeclarationParameterComma = true;
policy.SpaceAfterMethodDeclarationParameterComma = false;
@ -976,7 +976,7 @@ return (Test)null; @@ -976,7 +976,7 @@ return (Test)null;
[Test()]
public void TestAfterMethodDeclarationParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeMethodDeclarationParameterComma = false;
policy.SpaceAfterMethodDeclarationParameterComma = true;
@ -997,7 +997,7 @@ return (Test)null; @@ -997,7 +997,7 @@ return (Test)null;
[Test()]
public void TestSpacesInLambdaExpression ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinWhileParentheses = true;
var result = GetResult (policy, @"class Test {
@ -1014,7 +1014,7 @@ return (Test)null; @@ -1014,7 +1014,7 @@ return (Test)null;
[Test()]
public void TestBeforeLocalVariableDeclarationComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeLocalVariableDeclarationComma = true;
policy.SpaceAfterLocalVariableDeclarationComma = false;
@ -1041,7 +1041,7 @@ return (Test)null; @@ -1041,7 +1041,7 @@ return (Test)null;
[Test()]
public void TestLocalVariableDeclarationComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeLocalVariableDeclarationComma = true;
policy.SpaceAfterLocalVariableDeclarationComma = true;
@ -1071,7 +1071,7 @@ return (Test)null; @@ -1071,7 +1071,7 @@ return (Test)null;
[Test()]
public void TestBeforeConstructorDeclarationParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeConstructorDeclarationParentheses = true;
var result = GetResult (policy, @"class Test
@ -1092,7 +1092,7 @@ return (Test)null; @@ -1092,7 +1092,7 @@ return (Test)null;
[Test()]
public void TestBeforeConstructorDeclarationParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeConstructorDeclarationParameterComma = true;
policy.SpaceAfterConstructorDeclarationParameterComma = false;
@ -1115,7 +1115,7 @@ return (Test)null; @@ -1115,7 +1115,7 @@ return (Test)null;
[Test()]
public void TestAfterConstructorDeclarationParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeConstructorDeclarationParameterComma = false;
policy.SpaceAfterConstructorDeclarationParameterComma = true;
@ -1136,7 +1136,7 @@ return (Test)null; @@ -1136,7 +1136,7 @@ return (Test)null;
[Test()]
public void TestWithinConstructorDeclarationParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceWithinConstructorDeclarationParentheses = true;
var result = GetResult (policy, @"class Test {
@ -1152,7 +1152,7 @@ return (Test)null; @@ -1152,7 +1152,7 @@ return (Test)null;
[Test()]
public void TestBetweenEmptyConstructorDeclarationParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBetweenEmptyConstructorDeclarationParentheses = true;
var result = GetResult (policy, @"class Test {
@ -1171,7 +1171,7 @@ return (Test)null; @@ -1171,7 +1171,7 @@ return (Test)null;
[Test()]
public void TestBeforeDelegateDeclarationParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeDelegateDeclarationParentheses = true;
var result = GetResult (policy, @"delegate void Test();");
@ -1182,7 +1182,7 @@ return (Test)null; @@ -1182,7 +1182,7 @@ return (Test)null;
[Test()]
public void TestBeforeDelegateDeclarationParenthesesComplex ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeDelegateDeclarationParentheses = true;
var result = GetResult (policy, "delegate void TestDelegate\t\t\t();");
@ -1193,7 +1193,7 @@ return (Test)null; @@ -1193,7 +1193,7 @@ return (Test)null;
[Test()]
public void TestBeforeDelegateDeclarationParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeDelegateDeclarationParameterComma = true;
policy.SpaceAfterDelegateDeclarationParameterComma = false;
@ -1213,7 +1213,7 @@ return (Test)null; @@ -1213,7 +1213,7 @@ return (Test)null;
[Test()]
public void TestAfterDelegateDeclarationParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeDelegateDeclarationParameterComma = false;
policy.SpaceAfterDelegateDeclarationParameterComma = true;
@ -1233,7 +1233,7 @@ return (Test)null; @@ -1233,7 +1233,7 @@ return (Test)null;
[Test()]
public void TestWithinDelegateDeclarationParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceWithinDelegateDeclarationParentheses = true;
var result = GetResult (policy, @"delegate void Test (int a);");
@ -1245,7 +1245,7 @@ return (Test)null; @@ -1245,7 +1245,7 @@ return (Test)null;
[Test()]
public void TestBetweenEmptyDelegateDeclarationParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBetweenEmptyDelegateDeclarationParentheses = true;
var result = GetResult (policy, @"delegate void Test();");
@ -1260,7 +1260,7 @@ return (Test)null; @@ -1260,7 +1260,7 @@ return (Test)null;
[Test()]
public void TestBeforeMethodCallParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeMethodCallParentheses = true;
var result = GetResult (policy, @"class FooBar
@ -1283,7 +1283,7 @@ return (Test)null; @@ -1283,7 +1283,7 @@ return (Test)null;
[Test()]
public void TestBeforeMethodCallParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeMethodCallParameterComma = true;
policy.SpaceAfterMethodCallParameterComma = false;
@ -1308,7 +1308,7 @@ return (Test)null; @@ -1308,7 +1308,7 @@ return (Test)null;
[Test()]
public void TestAfterMethodCallParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeMethodCallParameterComma = false;
policy.SpaceAfterMethodCallParameterComma = true;
@ -1333,7 +1333,7 @@ return (Test)null; @@ -1333,7 +1333,7 @@ return (Test)null;
[Test()]
public void TestWithinMethodCallParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceWithinMethodCallParentheses = true;
var result = GetResult (policy, @"class FooBar
@ -1351,7 +1351,7 @@ return (Test)null; @@ -1351,7 +1351,7 @@ return (Test)null;
[Test()]
public void TestBetweenEmptyMethodCallParentheses ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBetweenEmptyMethodCallParentheses = true;
var result = GetResult (policy, @"class FooBar
@ -1373,7 +1373,7 @@ return (Test)null; @@ -1373,7 +1373,7 @@ return (Test)null;
public void TestBeforeIndexerDeclarationBracket ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeIndexerDeclarationBracket = true;
var result = GetResult (policy, @"class FooBar
@ -1397,7 +1397,7 @@ return (Test)null; @@ -1397,7 +1397,7 @@ return (Test)null;
[Test()]
public void TestBeforeIndexerDeclarationParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeIndexerDeclarationParameterComma = true;
policy.SpaceAfterIndexerDeclarationParameterComma = false;
@ -1418,7 +1418,7 @@ return (Test)null; @@ -1418,7 +1418,7 @@ return (Test)null;
[Test()]
public void TestAfterIndexerDeclarationParameterComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAfterIndexerDeclarationParameterComma = true;
var result = GetResult (policy, @"class FooBar
@ -1437,7 +1437,7 @@ return (Test)null; @@ -1437,7 +1437,7 @@ return (Test)null;
[Test()]
public void TestWithinIndexerDeclarationBracket ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceWithinIndexerDeclarationBracket = true;
var result = GetResult (policy, @"class FooBar
@ -1460,7 +1460,7 @@ return (Test)null; @@ -1460,7 +1460,7 @@ return (Test)null;
[Test()]
public void TestSpacesWithinBrackets ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesWithinBrackets = true;
policy.SpacesBeforeBrackets = false;
@ -1484,7 +1484,7 @@ return (Test)null; @@ -1484,7 +1484,7 @@ return (Test)null;
[Test()]
public void TestSpacesBeforeBrackets ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpacesBeforeBrackets = true;
var result = GetResult (policy, @"class Test
@ -1508,7 +1508,7 @@ return (Test)null; @@ -1508,7 +1508,7 @@ return (Test)null;
[Test()]
public void TestBeforeBracketComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeBracketComma = true;
policy.SpaceAfterBracketComma = false;
@ -1527,7 +1527,7 @@ return (Test)null; @@ -1527,7 +1527,7 @@ return (Test)null;
[Test()]
public void TestAfterBracketComma ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceAfterBracketComma = true;
var result = GetResult (policy, @"class Test {
@ -1547,7 +1547,7 @@ return (Test)null; @@ -1547,7 +1547,7 @@ return (Test)null;
[Test()]
public void TestSpacesBeforeArrayDeclarationBrackets ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.SpaceBeforeArrayDeclarationBrackets = true;
var result = GetResult (policy, @"class Test {
@ -1567,7 +1567,7 @@ return (Test)null; @@ -1567,7 +1567,7 @@ return (Test)null;
[Test()]
public void TestRemoveWhitespacesBeforeSemicolon ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
var result = GetResult (policy, @"class Test {
void TestMe ()
{

120
ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestInvocationIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy,
@ -58,7 +58,7 @@ this.TestMethod (); @@ -58,7 +58,7 @@ this.TestMethod ();
[Test()]
public void TestIndentBlocks ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentBlocks = true;
var adapter = Test (policy,
@ -94,7 +94,7 @@ this.TestMethod (); @@ -94,7 +94,7 @@ this.TestMethod ();
[Test()]
public void TestBreakIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy,
@ -115,7 +115,7 @@ this.TestMethod (); @@ -115,7 +115,7 @@ this.TestMethod ();
[Test()]
public void TestCheckedIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
@ -137,7 +137,7 @@ checked { @@ -137,7 +137,7 @@ checked {
[Test()]
public void TestBaseIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -156,7 +156,7 @@ checked { @@ -156,7 +156,7 @@ checked {
[Test()]
public void TestUncheckedIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -178,7 +178,7 @@ unchecked { @@ -178,7 +178,7 @@ unchecked {
[Test()]
public void TestContinueIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -198,7 +198,7 @@ continue; @@ -198,7 +198,7 @@ continue;
[Test()]
public void TestEmptyStatementIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -217,7 +217,7 @@ continue; @@ -217,7 +217,7 @@ continue;
[Test()]
public void TestFixedStatementIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -239,7 +239,7 @@ fixed (object* obj = &obj) @@ -239,7 +239,7 @@ fixed (object* obj = &obj)
[Test()]
public void TestFixedForcementAdd ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
policy.FixedBraceForcement = BraceForcement.AddBraces;
@ -269,7 +269,7 @@ fixed (object* obj = &obj) @@ -269,7 +269,7 @@ fixed (object* obj = &obj)
[Test()]
public void TestForeachIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test
@ -292,7 +292,7 @@ foreach (var obj in col) { @@ -292,7 +292,7 @@ foreach (var obj in col) {
[Test()]
public void TestForIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
@ -314,7 +314,7 @@ for (;;) { @@ -314,7 +314,7 @@ for (;;) {
[Test()]
public void TestGotoIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -334,7 +334,7 @@ goto label; @@ -334,7 +334,7 @@ goto label;
[Test()]
public void TestReturnIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -354,7 +354,7 @@ return; @@ -354,7 +354,7 @@ return;
[Test()]
public void TestLockIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -376,7 +376,7 @@ lock (this) { @@ -376,7 +376,7 @@ lock (this) {
[Test()]
public void TestThrowIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
@ -397,7 +397,7 @@ throw new NotSupportedException (); @@ -397,7 +397,7 @@ throw new NotSupportedException ();
[Test()]
public void TestUnsafeIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
@ -420,7 +420,7 @@ unsafe { @@ -420,7 +420,7 @@ unsafe {
[Test()]
public void TestUsingIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
@ -442,7 +442,7 @@ using (var o = new MyObj()) { @@ -442,7 +442,7 @@ using (var o = new MyObj()) {
[Test()]
public void TestUsingForcementAdd ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
policy.UsingBraceForcement = BraceForcement.AddBraces;
@ -472,7 +472,7 @@ using (var o = new MyObj()) { @@ -472,7 +472,7 @@ using (var o = new MyObj()) {
[Test()]
public void TestUsingForcementDoNotChange ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
policy.UsingBraceForcement = BraceForcement.DoNotChange;
@ -501,7 +501,7 @@ using (var o = new MyObj()) { @@ -501,7 +501,7 @@ using (var o = new MyObj()) {
[Test()]
public void TestUsingAlignment ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.AlignEmbeddedUsingStatements = true;
policy.ClassBraceStyle = BraceStyle.EndOfLine;
@ -535,7 +535,7 @@ using (var o = new MyObj()) { @@ -535,7 +535,7 @@ using (var o = new MyObj()) {
[Test()]
public void TestVariableDeclarationIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -555,7 +555,7 @@ Test a; @@ -555,7 +555,7 @@ Test a;
[Test()]
public void TestConstantVariableDeclarationIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -575,7 +575,7 @@ const int a = 5; @@ -575,7 +575,7 @@ const int a = 5;
[Test()]
public void TestYieldIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -595,7 +595,7 @@ yield return null; @@ -595,7 +595,7 @@ yield return null;
[Test()]
public void TestWhileIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
@ -618,7 +618,7 @@ while (true) @@ -618,7 +618,7 @@ while (true)
[Test()]
public void TestDoWhileIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test {
@ -640,7 +640,7 @@ do { @@ -640,7 +640,7 @@ do {
[Test()]
public void TestForeachBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
Test (policy, @"class Test
@ -663,7 +663,7 @@ do { @@ -663,7 +663,7 @@ do {
[Test()]
public void TestForeachBracketPlacement2 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.NextLineShifted2;
Test (policy, @"class Test
@ -688,7 +688,7 @@ do { @@ -688,7 +688,7 @@ do {
[Test()]
public void TestForEachBraceForcementAdd ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.NextLine;
policy.ForEachBraceForcement = BraceForcement.AddBraces;
@ -720,7 +720,7 @@ do { @@ -720,7 +720,7 @@ do {
[Test()]
public void TestForBraceForcementAdd ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.NextLine;
policy.ForBraceForcement = BraceForcement.AddBraces;
@ -753,7 +753,7 @@ do { @@ -753,7 +753,7 @@ do {
[Test()]
public void TestForEachBraceForcementRemove ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.NextLine;
policy.ForEachBraceForcement = BraceForcement.RemoveBraces;
@ -790,7 +790,7 @@ do { @@ -790,7 +790,7 @@ do {
[Test()]
public void TestIfBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
@ -814,7 +814,7 @@ do { @@ -814,7 +814,7 @@ do {
[Test()]
public void TestAllowIfBlockInline ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
policy.AllowIfBlockInline = true;
@ -884,7 +884,7 @@ do { @@ -884,7 +884,7 @@ do {
[Test()]
public void TestIfElseBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
@ -909,7 +909,7 @@ do { @@ -909,7 +909,7 @@ do {
[Test()]
public void TestIfForcementRemove ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.NextLine;
policy.IfElseBraceForcement = BraceForcement.RemoveBraces;
@ -947,7 +947,7 @@ do { @@ -947,7 +947,7 @@ do {
[Test()]
public void TestIfAlignment ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.AlignEmbeddedIfStatements = true;
policy.ClassBraceStyle = BraceStyle.EndOfLine;
@ -981,7 +981,7 @@ if (b) { @@ -981,7 +981,7 @@ if (b) {
[Test()]
public void TestIfForcementAdd ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
policy.IfElseBraceForcement = BraceForcement.AddBraces;
@ -1008,7 +1008,7 @@ if (b) { @@ -1008,7 +1008,7 @@ if (b) {
[Test()]
public void TestIfForcementWithComment ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
policy.IfElseBraceForcement = BraceForcement.AddBraces;
@ -1036,7 +1036,7 @@ if (b) { @@ -1036,7 +1036,7 @@ if (b) {
[Test()]
public void TestIfElseForcementAdd ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
policy.IfElseBraceForcement = BraceForcement.AddBraces;
@ -1067,7 +1067,7 @@ if (b) { @@ -1067,7 +1067,7 @@ if (b) {
[Test()]
public void TestIfElseIFForcementAdd ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
policy.IfElseBraceForcement = BraceForcement.AddBraces;
@ -1098,7 +1098,7 @@ if (b) { @@ -1098,7 +1098,7 @@ if (b) {
[Test()]
public void TestElseOnNewLine ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PlaceElseOnNewLine = true;
Test (policy, @"class Test
@ -1129,7 +1129,7 @@ if (b) { @@ -1129,7 +1129,7 @@ if (b) {
[Test()]
public void TestElseIfOnNewLine ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PlaceElseIfOnNewLine = true;
Test (policy, @"class Test
@ -1160,7 +1160,7 @@ if (b) { @@ -1160,7 +1160,7 @@ if (b) {
[Test()]
public void TestElseOnNewLineOff ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PlaceElseOnNewLine = false;
Test (policy, @"class Test
@ -1191,7 +1191,7 @@ if (b) { @@ -1191,7 +1191,7 @@ if (b) {
[Test()]
public void TestSimpleIfElseComment ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
policy.PlaceElseIfOnNewLine = false; // for simple statements it must be new line.
@ -1218,7 +1218,7 @@ if (b) { @@ -1218,7 +1218,7 @@ if (b) {
[Test()]
public void TestWhileForcementRemove ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.NextLine;
policy.WhileBraceForcement = BraceForcement.RemoveBraces;
@ -1256,7 +1256,7 @@ if (b) { @@ -1256,7 +1256,7 @@ if (b) {
[Test()]
public void TestFixedBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.NextLineShifted;
policy.FixedBraceForcement = BraceForcement.AddBraces;
@ -1285,7 +1285,7 @@ if (b) { @@ -1285,7 +1285,7 @@ if (b) {
[Test()]
public void TestForBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLineWithoutSpace;
Test (policy, @"class Test
@ -1309,7 +1309,7 @@ if (b) { @@ -1309,7 +1309,7 @@ if (b) {
[Test()]
public void TestCheckedBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLineWithoutSpace;
@ -1334,7 +1334,7 @@ if (b) { @@ -1334,7 +1334,7 @@ if (b) {
[Test()]
public void TestUncheckedBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLineWithoutSpace;
@ -1359,7 +1359,7 @@ if (b) { @@ -1359,7 +1359,7 @@ if (b) {
[Test()]
public void TestLockBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
@ -1387,7 +1387,7 @@ if (b) { @@ -1387,7 +1387,7 @@ if (b) {
[Test()]
public void TestUnsafeBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
@ -1415,7 +1415,7 @@ if (b) { @@ -1415,7 +1415,7 @@ if (b) {
[Test()]
public void TestUsingBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
@ -1443,7 +1443,7 @@ if (b) { @@ -1443,7 +1443,7 @@ if (b) {
[Test()]
public void TestWhileBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
@ -1471,7 +1471,7 @@ if (b) { @@ -1471,7 +1471,7 @@ if (b) {
[Test()]
public void TestDoWhileBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
@ -1499,7 +1499,7 @@ if (b) { @@ -1499,7 +1499,7 @@ if (b) {
[Test()]
public void TestSwitchFormatting1 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentSwitchBody = true;
policy.IndentCaseBody = true;
@ -1532,7 +1532,7 @@ if (b) { @@ -1532,7 +1532,7 @@ if (b) {
[Test()]
public void TestSwitchFormatting2 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentSwitchBody = false;
policy.IndentCaseBody = false;
@ -1565,7 +1565,7 @@ if (b) { @@ -1565,7 +1565,7 @@ if (b) {
[Test()]
public void TestTryCatchBracketPlacement ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.StatementBraceStyle = BraceStyle.EndOfLine;
@ -1592,7 +1592,7 @@ if (b) { @@ -1592,7 +1592,7 @@ if (b) {
[Test()]
public void TestPlaceCatchOnNewLine ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PlaceCatchOnNewLine = true;
@ -1624,7 +1624,7 @@ if (b) { @@ -1624,7 +1624,7 @@ if (b) {
[Test()]
public void TestPlaceFinallyOnNewLine ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PlaceFinallyOnNewLine = true;
Test (policy, @"class Test
@ -1655,7 +1655,7 @@ if (b) { @@ -1655,7 +1655,7 @@ if (b) {
[Test()]
public void TestPlaceWhileOnNewLine ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PlaceWhileOnNewLine = true;

40
ICSharpCode.NRefactory.Tests/FormattingTests/TestTypeLevelIndentation.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestClassIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.DoNotChange;
Test (policy,
@ -49,7 +49,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -49,7 +49,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestClassIndentationInNamespaces ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.NamespaceBraceStyle = BraceStyle.EndOfLine;
policy.ClassBraceStyle = BraceStyle.DoNotChange;
@ -63,7 +63,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -63,7 +63,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
[Test()]
public void TestNoIndentationInNamespaces ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.NamespaceBraceStyle = BraceStyle.EndOfLine;
policy.ClassBraceStyle = BraceStyle.DoNotChange;
policy.IndentNamespaceBody = false;
@ -78,7 +78,7 @@ class Test {} @@ -78,7 +78,7 @@ class Test {}
[Test()]
public void TestClassIndentationInNamespacesCase2 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.NamespaceBraceStyle = BraceStyle.NextLine;
policy.ClassBraceStyle = BraceStyle.NextLine;
policy.ConstructorBraceStyle = BraceStyle.NextLine;
@ -108,7 +108,7 @@ namespace MonoDevelop.CSharp.Formatting @@ -108,7 +108,7 @@ namespace MonoDevelop.CSharp.Formatting
[Test()]
public void TestIndentClassBody ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentClassBody = true;
Test (policy,
@"class Test
@ -134,7 +134,7 @@ Test a; @@ -134,7 +134,7 @@ Test a;
[Test()]
public void TestIndentInterfaceBody ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentInterfaceBody = true;
Test (policy,
@ -159,7 +159,7 @@ Test Foo (); @@ -159,7 +159,7 @@ Test Foo ();
[Test()]
public void TestIndentStructBody ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentStructBody = true;
Test (policy,
@ -184,7 +184,7 @@ Test Foo (); @@ -184,7 +184,7 @@ Test Foo ();
[Test()]
public void TestIndentEnumBody ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentEnumBody = true;
Test (policy,
@ -209,7 +209,7 @@ A @@ -209,7 +209,7 @@ A
[Test()]
public void TestIndentMethodBody ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentMethodBody = true;
Test (policy,
@ -252,7 +252,7 @@ A @@ -252,7 +252,7 @@ A
[Test()]
public void TestIndentMethodBodyOperatorCase ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentMethodBody = true;
var adapter = Test (policy,
@ -286,7 +286,7 @@ A @@ -286,7 +286,7 @@ A
[Test()]
public void TestIndentPropertyBody ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentPropertyBody = true;
var adapter = Test (policy,
@ -319,7 +319,7 @@ set; @@ -319,7 +319,7 @@ set;
[Test()]
public void TestIndentPropertyOneLine ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PropertyFormatting = PropertyFormatting.AllowOneLine;
policy.AllowPropertyGetBlockInline = true;
policy.AllowPropertySetBlockInline = true;
@ -338,7 +338,7 @@ set; @@ -338,7 +338,7 @@ set;
[Test()]
public void TestIndentPropertyOneLineCase2 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PropertyFormatting = PropertyFormatting.AllowOneLine;
policy.AllowPropertyGetBlockInline = true;
policy.AllowPropertySetBlockInline = true;
@ -357,7 +357,7 @@ set; @@ -357,7 +357,7 @@ set;
[Test()]
public void TestIndentPropertyBodyIndexerCase ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentPropertyBody = true;
var adapter = Test (policy,
@ -402,7 +402,7 @@ set { @@ -402,7 +402,7 @@ set {
[Test()]
public void TestPropertyAlignment ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PropertyFormatting = PropertyFormatting.AllowOneLine;
var adapter = Test (policy,
@"class Test
@ -435,7 +435,7 @@ set { @@ -435,7 +435,7 @@ set {
[Test()]
public void TestIndentNamespaceBody ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.ClassBraceStyle = BraceStyle.DoNotChange;
policy.NamespaceBraceStyle = BraceStyle.EndOfLine;
policy.IndentNamespaceBody = true;
@ -458,7 +458,7 @@ class FooBar {} @@ -458,7 +458,7 @@ class FooBar {}
[Test()]
public void TestMethodIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.MethodBraceStyle = BraceStyle.DoNotChange;
Test (policy,
@ -475,7 +475,7 @@ MyType TestMethod () {} @@ -475,7 +475,7 @@ MyType TestMethod () {}
[Test()]
public void TestPropertyIndentation ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.PropertyBraceStyle = BraceStyle.DoNotChange;
Test (policy,
@ -491,7 +491,7 @@ MyType TestMethod () {} @@ -491,7 +491,7 @@ MyType TestMethod () {}
[Test()]
public void TestPropertyIndentationCase2 ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
Test (policy,
@"class Test
@ -514,7 +514,7 @@ set; @@ -514,7 +514,7 @@ set;
[Test()]
public void TestIndentEventBody ()
{
CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentEventBody = true;
var adapter = Test (policy,

6
ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs

@ -221,7 +221,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -221,7 +221,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
public abstract class TestBase
{
protected static ITextEditorAdapter GetResult (CSharpFormattingPolicy policy, string input)
protected static ITextEditorAdapter GetResult (CSharpFormattingOptions policy, string input)
{
var adapter = new TextEditorTestAdapter (input);
var visitior = new AstFormattingVisitor (policy, adapter);
@ -233,7 +233,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -233,7 +233,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
return adapter;
}
protected static ITextEditorAdapter Test (CSharpFormattingPolicy policy, string input, string expectedOutput)
protected static ITextEditorAdapter Test (CSharpFormattingOptions policy, string input, string expectedOutput)
{
var adapter = new TextEditorTestAdapter (input);
var visitior = new AstFormattingVisitor (policy, adapter);
@ -245,7 +245,7 @@ namespace ICSharpCode.NRefactory.FormattingTests @@ -245,7 +245,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
return adapter;
}
protected static void Continue (CSharpFormattingPolicy policy, ITextEditorAdapter adapter, string expectedOutput)
protected static void Continue (CSharpFormattingOptions policy, ITextEditorAdapter adapter, string expectedOutput)
{
var visitior = new AstFormattingVisitor (policy, adapter);

8
ICSharpCode.NRefactory.Tests/ICSharpCode.NRefactory.Tests.csproj

@ -34,22 +34,24 @@ @@ -34,22 +34,24 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputPath>..\ICSharpCode.NRefactory\bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputPath>..\ICSharpCode.NRefactory\bin\Release\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="nunit.framework">
<HintPath>..\..\Mono.Cecil\Test\libs\nunit-2.4.8\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
</Reference>
<Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<HintPath>..\..\Mono.Cecil\Test\libs\nunit-2.4.8\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CSharp\Analysis\DefiniteAssignmentTests.cs" />

2
ICSharpCode.NRefactory.Tests/TypeSystem/GetAllBaseTypesTest.cs

@ -84,7 +84,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -84,7 +84,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
{
// class C<X> : C<C<X>> {}
DefaultTypeDefinition c = new DefaultTypeDefinition(mscorlib, string.Empty, "C");
c.TypeParameters.Add(new DefaultTypeParameter(c, 0, "X"));
c.TypeParameters.Add(new DefaultTypeParameter(EntityType.TypeDefinition, 0, "X"));
c.BaseTypes.Add(new ParameterizedType(c, new [] { new ParameterizedType(c, new [] { c.TypeParameters[0] }) }));
Assert.AreEqual(new [] { c }, c.GetAllBaseTypes(context).ToArray());
}

25
ICSharpCode.NRefactory.Tests/TypeSystem/TestInterningProvider.cs

@ -140,15 +140,36 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -140,15 +140,36 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
}
IProjectContent[] LoadProjects(CecilLoader loader)
{
const string dir = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\";
return new IProjectContent[] {
loader.LoadAssemblyFile(dir + "mscorlib.dll"),
loader.LoadAssemblyFile(dir + "System.dll"),
loader.LoadAssemblyFile(dir + "System.Core.dll"),
loader.LoadAssemblyFile(dir + "System.Xml.dll"),
loader.LoadAssemblyFile(dir + "System.Xml.Linq.dll"),
loader.LoadAssemblyFile(dir + "System.Data.dll"),
loader.LoadAssemblyFile(dir + "System.Drawing.dll"),
loader.LoadAssemblyFile(dir + "System.Windows.Forms.dll"),
loader.LoadAssemblyFile(dir + "WindowsBase.dll"),
loader.LoadAssemblyFile(dir + "PresentationCore.dll"),
loader.LoadAssemblyFile(dir + "PresentationFramework.dll")
};
}
[Test]
public void PrintStatistics()
{
long startMemory = GC.GetTotalMemory(true);
IProjectContent pc = new CecilLoader().LoadAssemblyFile(typeof(object).Assembly.Location);
IProjectContent[] pc = LoadProjects(new CecilLoader());
long memoryWithFullPC = GC.GetTotalMemory(true) - startMemory;
InterningProvider p = new InterningProvider();
p.InternProject(pc);
CecilLoader loader = new CecilLoader();
loader.InterningProvider = p;
pc = LoadProjects(loader);
PrintStatistics(p);
loader = null;
p = null;
long memoryWithInternedPC = GC.GetTotalMemory(true) - startMemory;
GC.KeepAlive(pc);

10
ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs

@ -134,8 +134,8 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -134,8 +134,8 @@ namespace ICSharpCode.NRefactory.TypeSystem
public void TestClassTypeParameters()
{
var testClass = testCasePC.GetClass(typeof(GenericClass<,>));
Assert.AreSame(testClass, testClass.TypeParameters[0].ParentClass);
Assert.AreSame(testClass, testClass.TypeParameters[1].ParentClass);
Assert.AreEqual(EntityType.TypeDefinition, testClass.TypeParameters[0].OwnerType);
Assert.AreEqual(EntityType.TypeDefinition, testClass.TypeParameters[1].OwnerType);
Assert.AreSame(testClass.TypeParameters[1], testClass.TypeParameters[0].Constraints[0].Resolve(ctx));
}
@ -147,8 +147,8 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -147,8 +147,8 @@ namespace ICSharpCode.NRefactory.TypeSystem
IMethod m = testClass.Methods.Single(me => me.Name == "TestMethod");
Assert.AreEqual("K", m.TypeParameters[0].Name);
Assert.AreEqual("V", m.TypeParameters[1].Name);
Assert.AreSame(m, m.TypeParameters[0].ParentMethod);
Assert.AreSame(m, m.TypeParameters[1].ParentMethod);
Assert.AreEqual(EntityType.Method, m.TypeParameters[0].OwnerType);
Assert.AreEqual(EntityType.Method, m.TypeParameters[1].OwnerType);
Assert.AreEqual("System.IComparable`1[[``1]]", m.TypeParameters[0].Constraints[0].Resolve(ctx).ReflectionName);
Assert.AreSame(m.TypeParameters[0], m.TypeParameters[1].Constraints[0].Resolve(ctx));
@ -161,7 +161,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -161,7 +161,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
IMethod m = testClass.Methods.Single(me => me.Name == "GetIndex");
Assert.AreEqual("T", m.TypeParameters[0].Name);
Assert.AreSame(m, m.TypeParameters[0].ParentMethod);
Assert.AreEqual(EntityType.Method, m.TypeParameters[0].OwnerType);
ParameterizedType constraint = (ParameterizedType)m.TypeParameters[0].Constraints[0].Resolve(ctx);
Assert.AreEqual("IEquatable", constraint.Name);

84
ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs

@ -31,11 +31,9 @@ using System.Diagnostics; @@ -31,11 +31,9 @@ using System.Diagnostics;
using System.Linq;
using System.Threading;
using ICSharpCode.NRefactory.CSharp.PatternMatching;
namespace ICSharpCode.NRefactory.CSharp
{
public abstract class AstNode
public abstract class AstNode : PatternMatching.INode
{
#region Null
public static readonly AstNode Null = new NullAstNode ();
@ -66,6 +64,42 @@ namespace ICSharpCode.NRefactory.CSharp @@ -66,6 +64,42 @@ namespace ICSharpCode.NRefactory.CSharp
}
#endregion
#region PatternPlaceholder
public static implicit operator AstNode(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : AstNode, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
AstNode parent;
AstNode prevSibling;
AstNode nextSibling;
@ -562,38 +596,32 @@ namespace ICSharpCode.NRefactory.CSharp @@ -562,38 +596,32 @@ namespace ICSharpCode.NRefactory.CSharp
public abstract S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data);
#region Pattern Matching
/// <summary>
/// Performs a pattern matching operation.
/// <c>this</c> is the pattern, <paramref name="other"/> is the AST that is being matched.
/// </summary>
/// <returns>
/// If successful, a match object containing the matched groups.
/// If the match failed, returns <c>null</c>.
/// </returns>
/// <remarks>
/// Patterns are ASTs that contain special pattern nodes (from the PatternMatching namespace).
/// However, it is also possible to match two ASTs without any pattern nodes - doing so will produce an empty match object
/// if the two ASTs are structurally identical; or will return <c>null</c> if the ASTs are not identical.
/// </remarks>
public Match Match(AstNode other)
{
Match match = new Match();
if (DoMatch(other, match))
return match;
else
return null;
}
protected static bool MatchString(string name1, string name2)
{
return string.IsNullOrEmpty(name1) || name1 == name2;
}
protected internal abstract bool DoMatch(AstNode other, Match match);
protected internal abstract bool DoMatch(AstNode other, PatternMatching.Match match);
internal virtual bool DoMatchCollection (Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack)
bool PatternMatching.INode.DoMatch(PatternMatching.INode other, PatternMatching.Match match)
{
return DoMatch (pos, match);
AstNode o = other as AstNode;
// try matching if other is null, or if other is an AstNode
return (other == null || o != null) && DoMatch(o, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
AstNode o = pos as AstNode;
return (pos == null || o != null) && DoMatch (o, match);
}
PatternMatching.INode PatternMatching.INode.NextSibling {
get { return nextSibling; }
}
PatternMatching.INode PatternMatching.INode.FirstChild {
get { return firstChild; }
}
#endregion

36
ICSharpCode.NRefactory/CSharp/Ast/AstNodeCollection.cs

@ -6,7 +6,7 @@ using System.Collections; @@ -6,7 +6,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using ICSharpCode.NRefactory.CSharp.PatternMatching;
using ICSharpCode.NRefactory.PatternMatching;
namespace ICSharpCode.NRefactory.CSharp
{
@ -159,39 +159,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -159,39 +159,7 @@ namespace ICSharpCode.NRefactory.CSharp
internal bool DoMatch(AstNodeCollection<T> other, Match match)
{
Stack<AstNode> patternStack = new Stack<AstNode>();
Stack<Pattern.PossibleMatch> stack = new Stack<Pattern.PossibleMatch>();
patternStack.Push(this.node.FirstChild);
stack.Push(new Pattern.PossibleMatch(other.node.FirstChild, match.CheckPoint()));
while (stack.Count > 0) {
AstNode cur1 = patternStack.Pop();
AstNode cur2 = stack.Peek().NextOther;
match.RestoreCheckPoint(stack.Pop().Checkpoint);
bool success = true;
while (cur1 != null && success) {
while (cur1 != null && cur1.Role != role)
cur1 = cur1.NextSibling;
while (cur2 != null && cur2.Role != role)
cur2 = cur2.NextSibling;
if (cur1 == null)
break;
Debug.Assert(stack.Count == patternStack.Count);
success = cur1.DoMatchCollection(role, cur2, match, stack);
Debug.Assert(stack.Count >= patternStack.Count);
while (stack.Count > patternStack.Count)
patternStack.Push(cur1.NextSibling);
cur1 = cur1.NextSibling;
if (cur2 != null)
cur2 = cur2.NextSibling;
}
while (cur2 != null && cur2.Role != role)
cur2 = cur2.NextSibling;
if (success && cur2 == null)
return true;
}
return false;
return Pattern.DoMatchCollection(role, node.FirstChild, other.node.FirstChild, match);
}
public void InsertAfter(T existingItem, T newItem)

58
ICSharpCode.NRefactory/CSharp/Ast/AstType.cs

@ -31,20 +31,78 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,20 +31,78 @@ namespace ICSharpCode.NRefactory.CSharp
}
#endregion
#region PatternPlaceholder
public static implicit operator AstType(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : AstType, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public override NodeType NodeType {
get { return NodeType.TypeReference; }
}
public new AstType Clone()
{
return (AstType)base.Clone();
}
/// <summary>
/// Creates a pointer type from this type by nesting it in a <see cref="ComposedType"/>.
/// If this type already is a pointer type, this method just increases the PointerRank of the existing pointer type.
/// </summary>
public virtual AstType MakePointerType()
{
return new ComposedType { BaseType = this }.MakePointerType();
}
/// <summary>
/// Creates an array type from this type by nesting it in a <see cref="ComposedType"/>.
/// If this type already is an array type, the additional rank is prepended to the existing array specifier list.
/// Thus, <c>new SimpleType("T").MakeArrayType(1).MakeArrayType(2)</c> will result in "T[,][]".
/// </summary>
public virtual AstType MakeArrayType(int rank = 1)
{
return new ComposedType { BaseType = this }.MakeArrayType(rank);
}
/// <summary>
/// Creates a nullable type from this type by nesting it in a <see cref="ComposedType"/>.
/// </summary>
public AstType MakeNullableType()
{
return new ComposedType { BaseType = this, HasNullableSpecifier = true };
}
/// <summary>
/// Builds an expression that can be used to access a static member on this type.
/// </summary>

14
ICSharpCode.NRefactory/CSharp/Ast/DepthFirstAstVisitor.cs

@ -440,6 +440,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -440,6 +440,11 @@ namespace ICSharpCode.NRefactory.CSharp
return VisitChildren (objectCreateExpression, data);
}
public virtual S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data)
{
return VisitChildren (anonymousTypeCreateExpression, data);
}
public virtual S VisitArrayCreateExpression (ArrayCreateExpression arrayObjectCreateExpression, T data)
{
return VisitChildren (arrayObjectCreateExpression, data);
@ -560,9 +565,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -560,9 +565,9 @@ namespace ICSharpCode.NRefactory.CSharp
return VisitChildren (defaultValueExpression, data);
}
public virtual S VisitArgListExpression (ArgListExpression argListExpression, T data)
public virtual S VisitUndocumentedExpression (UndocumentedExpression undocumentedExpression, T data)
{
return VisitChildren (argListExpression, data);
return VisitChildren (undocumentedExpression, data);
}
public virtual S VisitArrayInitializerExpression (ArrayInitializerExpression arrayInitializerExpression, T data)
@ -584,5 +589,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -584,5 +589,10 @@ namespace ICSharpCode.NRefactory.CSharp
{
return VisitChildren (emptyExpression, data);
}
public virtual S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data)
{
return VisitChildren (placeholder, data);
}
}
}

18
ICSharpCode.NRefactory/CSharp/Ast/Expressions/AnonymousMethodExpression.cs

@ -60,6 +60,24 @@ namespace ICSharpCode.NRefactory.CSharp @@ -60,6 +60,24 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Body, value); }
}
public AnonymousMethodExpression ()
{
}
public AnonymousMethodExpression (BlockStatement body, IEnumerable<ParameterDeclaration> parameters = null)
{
if (parameters != null) {
foreach (var parameter in parameters) {
AddChild (parameter, Roles.Parameter);
}
}
AddChild (body, Roles.Body);
}
public AnonymousMethodExpression (BlockStatement body, params ParameterDeclaration[] parameters) : this (body, (IEnumerable<ParameterDeclaration>)parameters)
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAnonymousMethodExpression (this, data);

79
ICSharpCode.NRefactory/CSharp/Ast/Expressions/AnonymousTypeCreateExpression.cs

@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
//
// AnonymousTypeCreateExpression.cs
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Collections.Generic;
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// new { [ExpressionList] }
/// </summary>
public class AnonymousTypeCreateExpression : Expression
{
public CSharpTokenNode NewToken {
get { return GetChildByRole (Roles.Keyword); }
}
public CSharpTokenNode LParToken {
get { return GetChildByRole (Roles.LPar); }
}
public AstNodeCollection<Expression> Initializer {
get { return GetChildrenByRole (Roles.Expression); }
}
public CSharpTokenNode RParToken {
get { return GetChildByRole (Roles.RPar); }
}
public AnonymousTypeCreateExpression ()
{
}
public AnonymousTypeCreateExpression (IEnumerable<Expression> initializer)
{
foreach (var ini in initializer) {
AddChild (ini, Roles.Expression);
}
}
public AnonymousTypeCreateExpression (params Expression[] initializer) : this ((IEnumerable<Expression>)initializer)
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAnonymousTypeCreateExpression (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
var o = other as AnonymousTypeCreateExpression;
return o != null && this.Initializer.DoMatch(o.Initializer, match);
}
}
}

10
ICSharpCode.NRefactory/CSharp/Ast/Expressions/AsExpression.cs

@ -45,6 +45,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -45,6 +45,16 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole(Roles.Type, value); }
}
public AsExpression ()
{
}
public AsExpression (Expression expression, AstType type)
{
AddChild (expression, Roles.Expression);
AddChild (type, Roles.Type);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAsExpression (this, data);

7
ICSharpCode.NRefactory/CSharp/Ast/Expressions/AssignmentExpression.cs

@ -48,6 +48,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -48,6 +48,13 @@ namespace ICSharpCode.NRefactory.CSharp
this.Right = right;
}
public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right)
{
this.Left = left;
this.Operator = op;
this.Right = right;
}
public AssignmentOperatorType Operator {
get;
set;

10
ICSharpCode.NRefactory/CSharp/Ast/Expressions/CastExpression.cs

@ -49,6 +49,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,6 +49,16 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Expression, value); }
}
public CastExpression ()
{
}
public CastExpression (AstType castToType, Expression expression)
{
AddChild (castToType, Roles.Type);
AddChild (expression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCastExpression (this, data);

9
ICSharpCode.NRefactory/CSharp/Ast/Expressions/CheckedExpression.cs

@ -48,6 +48,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -48,6 +48,15 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RPar); }
}
public CheckedExpression ()
{
}
public CheckedExpression (Expression expression)
{
AddChild (expression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCheckedExpression (this, data);

11
ICSharpCode.NRefactory/CSharp/Ast/Expressions/ConditionalExpression.cs

@ -60,6 +60,17 @@ namespace ICSharpCode.NRefactory.CSharp @@ -60,6 +60,17 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole(FalseRole, value); }
}
public ConditionalExpression ()
{
}
public ConditionalExpression (Expression condition, Expression trueExpression, Expression falseExpression)
{
AddChild (condition, ConditionRole);
AddChild (trueExpression, TrueRole);
AddChild (falseExpression, FalseRole);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitConditionalExpression (this, data);

9
ICSharpCode.NRefactory/CSharp/Ast/Expressions/DefaultValueExpression.cs

@ -48,6 +48,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -48,6 +48,15 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RPar); }
}
public DefaultValueExpression ()
{
}
public DefaultValueExpression (AstType type)
{
AddChild (type, Roles.Type);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDefaultValueExpression (this, data);

10
ICSharpCode.NRefactory/CSharp/Ast/Expressions/DirectionExpression.cs

@ -52,6 +52,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -52,6 +52,16 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Expression, value); }
}
public DirectionExpression ()
{
}
public DirectionExpression (FieldDirection direction, Expression expression)
{
this.FieldDirection = direction;
AddChild (expression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitDirectionExpression (this, data);

38
ICSharpCode.NRefactory/CSharp/Ast/Expressions/Expression.cs

@ -40,6 +40,42 @@ namespace ICSharpCode.NRefactory.CSharp @@ -40,6 +40,42 @@ namespace ICSharpCode.NRefactory.CSharp
}
#endregion
#region PatternPlaceholder
public static implicit operator Expression(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : Expression, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public override NodeType NodeType {
get {
return NodeType.Expression;
@ -57,7 +93,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -57,7 +93,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (IsNull)
return "Null";
StringWriter w = new StringWriter();
AcceptVisitor(new OutputVisitor(w, new CSharpFormattingPolicy()), null);
AcceptVisitor(new OutputVisitor(w, new CSharpFormattingOptions()), null);
return w.ToString();
}

18
ICSharpCode.NRefactory/CSharp/Ast/Expressions/IndexerExpression.cs

@ -50,6 +50,24 @@ namespace ICSharpCode.NRefactory.CSharp @@ -50,6 +50,24 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RBracket); }
}
public IndexerExpression ()
{
}
public IndexerExpression (Expression target, IEnumerable<Expression> arguments)
{
AddChild (target, Roles.TargetExpression);
if (arguments != null) {
foreach (var arg in arguments) {
AddChild (arg, Roles.Argument);
}
}
}
public IndexerExpression (Expression target, params Expression[] arguments) : this (target, (IEnumerable<Expression>)arguments)
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIndexerExpression (this, data);

18
ICSharpCode.NRefactory/CSharp/Ast/Expressions/InvocationExpression.cs

@ -55,6 +55,24 @@ namespace ICSharpCode.NRefactory.CSharp @@ -55,6 +55,24 @@ namespace ICSharpCode.NRefactory.CSharp
return visitor.VisitInvocationExpression (this, data);
}
public InvocationExpression ()
{
}
public InvocationExpression (Expression target, IEnumerable<Expression> arguments)
{
AddChild (target, Roles.TargetExpression);
if (arguments != null) {
foreach (var arg in arguments) {
AddChild (arg, Roles.Argument);
}
}
}
public InvocationExpression (Expression target, params Expression[] arguments) : this (target, (IEnumerable<Expression>)arguments)
{
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
InvocationExpression o = other as InvocationExpression;

19
ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs

@ -59,6 +59,25 @@ namespace ICSharpCode.NRefactory.CSharp @@ -59,6 +59,25 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RChevron); }
}
public MemberReferenceExpression ()
{
}
public MemberReferenceExpression (Expression target, string memberName, IEnumerable<AstType> arguments = null)
{
AddChild (target, Roles.TargetExpression);
MemberName = memberName;
if (arguments != null) {
foreach (var arg in arguments) {
AddChild (arg, Roles.TypeArgument);
}
}
}
public MemberReferenceExpression (Expression target, string memberName, params AstType[] arguments) : this (target, memberName, (IEnumerable<AstType>)arguments)
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitMemberReferenceExpression (this, data);

4
ICSharpCode.NRefactory/CSharp/Ast/Expressions/NamedArgumentExpression.cs

@ -19,6 +19,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -19,6 +19,10 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public CSharpTokenNode AssignToken {
get { return GetChildByRole (Roles.Assign); }
}
public Expression Expression {
get { return GetChildByRole (Roles.Expression); }
set { SetChildByRole (Roles.Expression, value); }

22
ICSharpCode.NRefactory/CSharp/Ast/Expressions/NullReferenceExpression.cs

@ -31,6 +31,28 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,6 +31,28 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class NullReferenceExpression : Expression
{
AstLocation location;
public override AstLocation StartLocation {
get {
return location;
}
}
public override AstLocation EndLocation {
get {
return new AstLocation (location.Line, location.Column + "null".Length);
}
}
public NullReferenceExpression ()
{
}
public NullReferenceExpression (AstLocation location)
{
this.location = location;
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitNullReferenceExpression (this, data);

18
ICSharpCode.NRefactory/CSharp/Ast/Expressions/ObjectCreateExpression.cs

@ -61,6 +61,24 @@ namespace ICSharpCode.NRefactory.CSharp @@ -61,6 +61,24 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (InitializerRole, value); }
}
public ObjectCreateExpression ()
{
}
public ObjectCreateExpression (AstType type, IEnumerable<Expression> arguments = null)
{
AddChild (type, Roles.Type);
if (arguments != null) {
foreach (var arg in arguments) {
AddChild (arg, Roles.Argument);
}
}
}
public ObjectCreateExpression (AstType type, params Expression[] arguments) : this (type, (IEnumerable<Expression>)arguments)
{
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitObjectCreateExpression (this, data);

9
ICSharpCode.NRefactory/CSharp/Ast/Expressions/ParenthesizedExpression.cs

@ -44,6 +44,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -44,6 +44,15 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RPar); }
}
public ParenthesizedExpression()
{
}
public ParenthesizedExpression(Expression expr)
{
Expression = expr;
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitParenthesizedExpression (this, data);

9
ICSharpCode.NRefactory/CSharp/Ast/Expressions/SizeOfExpression.cs

@ -48,6 +48,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -48,6 +48,15 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RPar); }
}
public SizeOfExpression ()
{
}
public SizeOfExpression (AstType type)
{
AddChild (type, Roles.Type);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitSizeOfExpression (this, data);

9
ICSharpCode.NRefactory/CSharp/Ast/Expressions/TypeOfExpression.cs

@ -49,6 +49,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,6 +49,15 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RPar); }
}
public TypeOfExpression ()
{
}
public TypeOfExpression (AstType type)
{
AddChild (type, Roles.Type);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitTypeOfExpression (this, data);

9
ICSharpCode.NRefactory/CSharp/Ast/Expressions/TypeReferenceExpression.cs

@ -21,6 +21,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -21,6 +21,15 @@ namespace ICSharpCode.NRefactory.CSharp
return visitor.VisitTypeReferenceExpression(this, data);
}
public TypeReferenceExpression ()
{
}
public TypeReferenceExpression (AstType type)
{
AddChild (type, Roles.Type);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
TypeReferenceExpression o = other as TypeReferenceExpression;

9
ICSharpCode.NRefactory/CSharp/Ast/Expressions/UncheckedExpression.cs

@ -48,6 +48,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -48,6 +48,15 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RPar); }
}
public UncheckedExpression ()
{
}
public UncheckedExpression (Expression expression)
{
AddChild (expression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUncheckedExpression (this, data);

25
ICSharpCode.NRefactory/CSharp/Ast/Expressions/ArgListExpression.cs → ICSharpCode.NRefactory/CSharp/Ast/Expressions/UndocumentedExpression.cs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// ArgListExpression.cs
// UndocumentedExpression.cs
//
// Author:
// Mike Krüger <mkrueger@novell.com>
@ -28,16 +28,25 @@ using System.Collections.Generic; @@ -28,16 +28,25 @@ using System.Collections.Generic;
namespace ICSharpCode.NRefactory.CSharp
{
public enum UndocumentedExpressionType
{
ArgListAccess, // __arglist
ArgList, // __arglist (a1, a2, ..., an)
RefValue, // __refvalue (expr , type)
RefType, // __reftype (expr)
MakeRef // __makeref (expr)
}
/// <summary>
/// Represents the undocumented __arglist keyword.
/// Represents undocumented expressions.
/// </summary>
public class ArgListExpression : Expression
public class UndocumentedExpression : Expression
{
public bool IsAccess { // access is __arglist, otherwise it's __arglist (a1, a2, ..., an)
public UndocumentedExpressionType UndocumentedExpressionType {
get; set;
}
public CSharpTokenNode ArgListToken {
public CSharpTokenNode UndocumentedToken {
get { return GetChildByRole (Roles.Keyword); }
}
@ -55,13 +64,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -55,13 +64,13 @@ namespace ICSharpCode.NRefactory.CSharp
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitArgListExpression (this, data);
return visitor.VisitUndocumentedExpression (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ArgListExpression o = other as ArgListExpression;
return o != null && this.IsAccess == o.IsAccess && this.Arguments.DoMatch(o.Arguments, match);
UndocumentedExpression o = other as UndocumentedExpression;
return o != null && this.UndocumentedExpressionType == o.UndocumentedExpressionType && this.Arguments.DoMatch(o.Arguments, match);
}
}
}

92
ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/AttributeSection.cs

@ -35,6 +35,42 @@ namespace ICSharpCode.NRefactory.CSharp @@ -35,6 +35,42 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class AttributeSection : AstNode
{
#region PatternPlaceholder
public static implicit operator AttributeSection(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : AttributeSection, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public static readonly Role<Attribute> AttributeRole = new Role<Attribute>("Attribute");
public static readonly Role<CSharpTokenNode> TargetRole = new Role<CSharpTokenNode>("Target", CSharpTokenNode.Null);
@ -44,7 +80,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -44,7 +80,11 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public AttributeTarget AttributeTarget {
public CSharpTokenNode LBracketToken {
get { return GetChildByRole (Roles.LBracket); }
}
public string AttributeTarget {
get;
set;
}
@ -53,6 +93,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,6 +93,10 @@ namespace ICSharpCode.NRefactory.CSharp
get { return base.GetChildrenByRole (AttributeRole); }
}
public CSharpTokenNode RBracketToken {
get { return GetChildByRole (Roles.RBracket); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitAttributeSection (this, data);
@ -73,29 +117,29 @@ namespace ICSharpCode.NRefactory.CSharp @@ -73,29 +117,29 @@ namespace ICSharpCode.NRefactory.CSharp
this.Attributes.Add(attr);
}
public static string GetAttributeTargetName(AttributeTarget attributeTarget)
{
switch (attributeTarget) {
case AttributeTarget.None:
return null;
case AttributeTarget.Assembly:
return "assembly";
case AttributeTarget.Module:
return "module";
case AttributeTarget.Type:
return "type";
case AttributeTarget.Param:
return "param";
case AttributeTarget.Field:
return "field";
case AttributeTarget.Return:
return "return";
case AttributeTarget.Method:
return "method";
default:
throw new NotSupportedException("Invalid value for AttributeTarget");
}
}
// public static string GetAttributeTargetName(AttributeTarget attributeTarget)
// {
// switch (attributeTarget) {
// case AttributeTarget.None:
// return null;
// case AttributeTarget.Assembly:
// return "assembly";
// case AttributeTarget.Module:
// return "module";
// case AttributeTarget.Type:
// return "type";
// case AttributeTarget.Param:
// return "param";
// case AttributeTarget.Field:
// return "field";
// case AttributeTarget.Return:
// return "return";
// case AttributeTarget.Method:
// return "method";
// default:
// throw new NotSupportedException("Invalid value for AttributeTarget");
// }
// }
}
public enum AttributeTarget {

13
ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs

@ -86,6 +86,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -86,6 +86,15 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RBrace); }
}
public NamespaceDeclaration ()
{
}
public NamespaceDeclaration (string name)
{
this.Name = name;
}
public static string BuildQualifiedName (string name1, string name2)
{
if (string.IsNullOrEmpty (name1))
@ -95,6 +104,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -95,6 +104,10 @@ namespace ICSharpCode.NRefactory.CSharp
return name1 + "." + name2;
}
public void AddMember (AstNode child)
{
AddChild (child, MemberRole);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{

16
ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingAliasDeclaration.cs

@ -66,6 +66,22 @@ namespace ICSharpCode.NRefactory.CSharp @@ -66,6 +66,22 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Semicolon); }
}
public UsingAliasDeclaration ()
{
}
public UsingAliasDeclaration (string alias, string nameSpace)
{
AddChild (new Identifier (alias, AstLocation.Empty), AliasRole);
AddChild (new SimpleType (nameSpace), ImportRole);
}
public UsingAliasDeclaration (string alias, AstType import)
{
AddChild (new Identifier (alias, AstLocation.Empty), AliasRole);
AddChild (import, ImportRole);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUsingAliasDeclaration (this, data);

14
ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/UsingDeclaration.cs

@ -60,6 +60,20 @@ namespace ICSharpCode.NRefactory.CSharp @@ -60,6 +60,20 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Semicolon); }
}
public UsingDeclaration ()
{
}
public UsingDeclaration (string nameSpace)
{
AddChild (new SimpleType (nameSpace), ImportRole);
}
public UsingDeclaration (AstType import)
{
AddChild (import, ImportRole);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUsingDeclaration (this, data);

5
ICSharpCode.NRefactory/CSharp/Ast/IAstVisitor.cs

@ -11,7 +11,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -11,7 +11,7 @@ namespace ICSharpCode.NRefactory.CSharp
public interface IAstVisitor<in T, out S>
{
S VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, T data);
S VisitArgListExpression(ArgListExpression argListExpression, T data);
S VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, T data);
S VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, T data);
S VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, T data);
S VisitAsExpression(AsExpression asExpression, T data);
@ -32,6 +32,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -32,6 +32,7 @@ namespace ICSharpCode.NRefactory.CSharp
S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, T data);
S VisitNullReferenceExpression(NullReferenceExpression nullReferenceExpression, T data);
S VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, T data);
S VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, T data);
S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, T data);
S VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, T data);
S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data);
@ -124,5 +125,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -124,5 +125,7 @@ namespace ICSharpCode.NRefactory.CSharp
S VisitConstraint(Constraint constraint, T data);
S VisitCSharpTokenNode(CSharpTokenNode cSharpTokenNode, T data);
S VisitIdentifier(Identifier identifier, T data);
S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data);
}
}

10
ICSharpCode.NRefactory/CSharp/Ast/Identifier.cs

@ -66,6 +66,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -66,6 +66,11 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public bool IsQuoted {
get;
set;
}
AstLocation startLocation;
public override AstLocation StartLocation {
get {
@ -75,7 +80,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -75,7 +80,7 @@ namespace ICSharpCode.NRefactory.CSharp
public override AstLocation EndLocation {
get {
return new AstLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length);
return new AstLocation (StartLocation.Line, StartLocation.Column + (Name ?? "").Length + (IsQuoted ? 1 : 0));
}
}
@ -88,7 +93,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -88,7 +93,8 @@ namespace ICSharpCode.NRefactory.CSharp
{
if (name == null)
throw new ArgumentNullException("name");
this.Name = name;
IsQuoted = name.StartsWith ("@");
this.Name = IsQuoted ? name.Substring (1) : name;
this.startLocation = location;
}

7
ICSharpCode.NRefactory/CSharp/Ast/NodeType.cs

@ -44,8 +44,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -44,8 +44,9 @@ namespace ICSharpCode.NRefactory.CSharp
Expression,
Token,
QueryClause,
Pattern,
Placeholder
/// <summary>
/// Placeholder for a pattern
/// </summary>
Pattern
}
}

54
ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Choice.cs

@ -1,54 +0,0 @@ @@ -1,54 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.Collections;
using System.Collections.Generic;
namespace ICSharpCode.NRefactory.CSharp.PatternMatching
{
/// <summary>
/// Matches one of several alternatives.
/// </summary>
public class Choice : Pattern, IEnumerable<AstNode>
{
public static readonly Role<AstNode> AlternativeRole = new Role<AstNode>("Alternative", AstNode.Null);
public void Add(string name, AstNode alternative)
{
AddChild(new NamedNode(name, alternative), AlternativeRole);
}
public void Add(AstNode alternative)
{
AddChild(alternative, AlternativeRole);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
var checkPoint = match.CheckPoint();
foreach (AstNode alt in GetChildrenByRole(AlternativeRole)) {
if (alt.DoMatch(other, match))
return true;
else
match.RestoreCheckPoint(checkPoint);
}
return false;
}
IEnumerator<AstNode> IEnumerable<AstNode>.GetEnumerator()
{
return GetChildrenByRole(AlternativeRole).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetChildrenByRole(AlternativeRole).GetEnumerator();
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return ((IPatternAstVisitor<T, S>)visitor).VisitChoice(this, data);
}
}
}

42
ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/OptionalNode.cs

@ -1,42 +0,0 @@ @@ -1,42 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace ICSharpCode.NRefactory.CSharp.PatternMatching
{
public class OptionalNode : Pattern
{
public static readonly Role<AstNode> ElementRole = new Role<AstNode>("Element", AstNode.Null);
public OptionalNode(AstNode childNode)
{
AddChild(childNode, ElementRole);
}
public OptionalNode(string groupName, AstNode childNode) : this(new NamedNode(groupName, childNode))
{
}
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack)
{
backtrackingStack.Push(new PossibleMatch(pos, match.CheckPoint()));
return GetChildByRole(ElementRole).DoMatch(pos, match);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
if (other == null || other.IsNull)
return true;
else
return GetChildByRole(ElementRole).DoMatch(other, match);
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return ((IPatternAstVisitor<T, S>)visitor).VisitOptionalNode(this, data);
}
}
}

95
ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Pattern.cs

@ -1,95 +0,0 @@ @@ -1,95 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
namespace ICSharpCode.NRefactory.CSharp.PatternMatching
{
/// <summary>
/// Base class for all patterns.
/// </summary>
public abstract class Pattern : AstNode
{
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
internal struct PossibleMatch
{
public readonly AstNode NextOther; // next node after the last matched node
public readonly int Checkpoint; // checkpoint
public PossibleMatch(AstNode nextOther, int checkpoint)
{
this.NextOther = nextOther;
this.Checkpoint = checkpoint;
}
}
public static implicit operator AstType(Pattern p)
{
return p != null ? new TypePlaceholder(p) : null;
}
public AstType ToType()
{
return new TypePlaceholder(this);
}
public static implicit operator Expression(Pattern p)
{
return p != null ? new ExpressionPlaceholder(p) : null;
}
public Expression ToExpression()
{
return new ExpressionPlaceholder(this);
}
public static implicit operator Statement(Pattern p)
{
return p != null ? new StatementPlaceholder(p) : null;
}
public Statement ToStatement()
{
return new StatementPlaceholder(this);
}
public static implicit operator BlockStatement(Pattern p)
{
return p != null ? new BlockStatementPlaceholder(p) : null;
}
public static implicit operator VariableInitializer(Pattern p)
{
return p != null ? new VariablePlaceholder(p) : null;
}
public static implicit operator AttributeSection(Pattern p)
{
return p != null ? new AttributeSectionPlaceholder(p) : null;
}
public static implicit operator SwitchSection(Pattern p)
{
return p != null ? new SwitchSectionPlaceholder(p) : null;
}
public static implicit operator CatchClause(Pattern p)
{
return p != null ? new CatchClausePlaceholder(p) : null;
}
// Make debugging easier by giving Patterns a ToString() implementation
public override string ToString()
{
StringWriter w = new StringWriter();
AcceptVisitor(new OutputVisitor(w, new CSharpFormattingPolicy()), null);
return w.ToString();
}
}
}

242
ICSharpCode.NRefactory/CSharp/Ast/PatternMatching/Placeholder.cs

@ -1,242 +0,0 @@ @@ -1,242 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
namespace ICSharpCode.NRefactory.CSharp.PatternMatching
{
// Placeholders do not store their child in the AST tree; but keep it as a separate child.
// This allows reusing the child in multiple placeholders; thus enabling the sharing of AST subtrees.
sealed class TypePlaceholder : AstType
{
readonly AstNode child;
public TypePlaceholder(AstNode child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Placeholder; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return child.DoMatch(other, match);
}
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack)
{
return child.DoMatchCollection(role, pos, match, backtrackingStack);
}
}
sealed class ExpressionPlaceholder : Expression
{
readonly AstNode child;
public ExpressionPlaceholder(AstNode child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Placeholder; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return child.DoMatch(other, match);
}
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack)
{
return child.DoMatchCollection(role, pos, match, backtrackingStack);
}
}
sealed class StatementPlaceholder : Statement
{
readonly AstNode child;
public StatementPlaceholder(AstNode child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Placeholder; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return child.DoMatch(other, match);
}
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack)
{
return child.DoMatchCollection(role, pos, match, backtrackingStack);
}
}
sealed class BlockStatementPlaceholder : BlockStatement
{
readonly AstNode child;
public BlockStatementPlaceholder(AstNode child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Placeholder; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return child.DoMatch(other, match);
}
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack)
{
return child.DoMatchCollection(role, pos, match, backtrackingStack);
}
}
sealed class VariablePlaceholder : VariableInitializer
{
readonly AstNode child;
public VariablePlaceholder(AstNode child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Placeholder; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return child.DoMatch(other, match);
}
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack)
{
return child.DoMatchCollection(role, pos, match, backtrackingStack);
}
}
sealed class AttributeSectionPlaceholder : AttributeSection
{
readonly AstNode child;
public AttributeSectionPlaceholder(AstNode child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Placeholder; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return child.DoMatch(other, match);
}
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack)
{
return child.DoMatchCollection(role, pos, match, backtrackingStack);
}
}
sealed class SwitchSectionPlaceholder : SwitchSection
{
readonly AstNode child;
public SwitchSectionPlaceholder(AstNode child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Placeholder; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return child.DoMatch(other, match);
}
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack)
{
return child.DoMatchCollection(role, pos, match, backtrackingStack);
}
}
sealed class CatchClausePlaceholder : CatchClause
{
readonly AstNode child;
public CatchClausePlaceholder(AstNode child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Placeholder; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return ((IPatternAstVisitor<T, S>)visitor).VisitPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, Match match)
{
return child.DoMatch(other, match);
}
internal override bool DoMatchCollection(Role role, AstNode pos, Match match, Stack<Pattern.PossibleMatch> backtrackingStack)
{
return child.DoMatchCollection(role, pos, match, backtrackingStack);
}
}
}

36
ICSharpCode.NRefactory/CSharp/Ast/Statements/BlockStatement.cs

@ -57,6 +57,42 @@ namespace ICSharpCode.NRefactory.CSharp @@ -57,6 +57,42 @@ namespace ICSharpCode.NRefactory.CSharp
}
#endregion
#region PatternPlaceholder
public static implicit operator BlockStatement(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : BlockStatement, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public CSharpTokenNode LBraceToken {
get { return GetChildByRole (Roles.LBrace); }
}

11
ICSharpCode.NRefactory/CSharp/Ast/Statements/CheckedStatement.cs

@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// checked { Body }
/// checked BodyBlock
/// </summary>
public class CheckedStatement : Statement
{
@ -40,6 +40,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -40,6 +40,15 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Body, value); }
}
public CheckedStatement ()
{
}
public CheckedStatement (BlockStatement body)
{
AddChild (body, Roles.Body);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitCheckedStatement (this, data);

9
ICSharpCode.NRefactory/CSharp/Ast/Statements/ReturnStatement.cs

@ -44,6 +44,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -44,6 +44,15 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Semicolon); }
}
public ReturnStatement ()
{
}
public ReturnStatement (Expression returnExpression)
{
AddChild (returnExpression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitReturnStatement (this, data);

60
ICSharpCode.NRefactory/CSharp/Ast/Statements/Statement.cs

@ -38,37 +38,41 @@ namespace ICSharpCode.NRefactory.CSharp @@ -38,37 +38,41 @@ namespace ICSharpCode.NRefactory.CSharp
}
#endregion
/// <summary>
/// Gets the previous statement within the current block.
/// This is usually equivalent to <see cref="PrevSibling"/>, but will skip any non-statements (e.g. comments)
/// </summary>
public Statement PreviousStatement {
get {
AstNode node = this;
while ((node = node.PrevSibling) != null) {
Statement stmt = node as Statement;
if (stmt != null)
return stmt;
}
return null;
}
#region PatternPlaceholder
public static implicit operator Statement(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
/// <summary>
/// Gets the next statement within the current block.
/// This is usually equivalent to <see cref="NextSibling"/>, but will skip any non-statements (e.g. comments)
/// </summary>
public Statement NextStatement {
get {
AstNode node = this;
while ((node = node.NextSibling) != null) {
Statement stmt = node as Statement;
if (stmt != null)
return stmt;
}
return null;
sealed class PatternPlaceholder : Statement, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public new Statement Clone()
{
@ -92,7 +96,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -92,7 +96,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (IsNull)
return "Null";
StringWriter w = new StringWriter();
AcceptVisitor(new OutputVisitor(w, new CSharpFormattingPolicy()), null);
AcceptVisitor(new OutputVisitor(w, new CSharpFormattingOptions()), null);
string text = w.ToString().TrimEnd().Replace("\t", "").Replace(w.NewLine, " ");
if (text.Length > 100)
return text.Substring(0, 97) + "...";

36
ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs

@ -79,6 +79,42 @@ namespace ICSharpCode.NRefactory.CSharp @@ -79,6 +79,42 @@ namespace ICSharpCode.NRefactory.CSharp
public class SwitchSection : AstNode
{
#region PatternPlaceholder
public static implicit operator SwitchSection(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : SwitchSection, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public static readonly Role<CaseLabel> CaseLabelRole = new Role<CaseLabel>("CaseLabel");
public override NodeType NodeType {

9
ICSharpCode.NRefactory/CSharp/Ast/Statements/ThrowStatement.cs

@ -44,6 +44,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -44,6 +44,15 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Semicolon); }
}
public ThrowStatement ()
{
}
public ThrowStatement (Expression expression)
{
AddChild (expression, Roles.Expression);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitThrowStatement (this, data);

36
ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs

@ -79,6 +79,42 @@ namespace ICSharpCode.NRefactory.CSharp @@ -79,6 +79,42 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public class CatchClause : AstNode
{
#region PatternPlaceholder
public static implicit operator CatchClause(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : CatchClause, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public override NodeType NodeType {
get {
return NodeType.Unknown;

11
ICSharpCode.NRefactory/CSharp/Ast/Statements/UncheckedStatement.cs

@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// unchecked { Body }
/// unchecked BodyBlock
/// </summary>
public class UncheckedStatement : Statement
{
@ -40,6 +40,15 @@ namespace ICSharpCode.NRefactory.CSharp @@ -40,6 +40,15 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Body, value); }
}
public UncheckedStatement ()
{
}
public UncheckedStatement (BlockStatement body)
{
AddChild (body, Roles.Body);
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitUncheckedStatement (this, data);

8
ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs

@ -123,10 +123,18 @@ namespace ICSharpCode.NRefactory.CSharp @@ -123,10 +123,18 @@ namespace ICSharpCode.NRefactory.CSharp
set;
}
public CSharpTokenNode LParToken {
get { return GetChildByRole (Roles.LPar); }
}
public AstNodeCollection<Expression> Arguments {
get { return GetChildrenByRole (Roles.Argument); }
}
public CSharpTokenNode RParToken {
get { return GetChildByRole (Roles.RPar); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitConstructorInitializer (this, data);

12
ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FixedVariableInitializer.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// FixedFieldDeclaration.cs
//
// Author:
@ -29,7 +29,7 @@ using System; @@ -29,7 +29,7 @@ using System;
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// name [ <expression> ]
/// Name [ CountExpression ]
/// </summary>
public class FixedVariableInitializer : AstNode
{
@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -46,7 +46,7 @@ namespace ICSharpCode.NRefactory.CSharp
public FixedVariableInitializer (string name, Expression initializer = null)
{
this.Name = name;
this.Initializer = initializer;
this.CountExpression = initializer;
}
public string Name {
@ -62,7 +62,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -62,7 +62,7 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LBracket); }
}
public Expression Initializer {
public Expression CountExpression {
get { return GetChildByRole (Roles.Expression); }
set { SetChildByRole (Roles.Expression, value); }
}
@ -76,10 +76,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -76,10 +76,10 @@ namespace ICSharpCode.NRefactory.CSharp
return visitor.VisitFixedVariableInitializer (this, data);
}
protected internal override bool DoMatch (AstNode other, ICSharpCode.NRefactory.CSharp.PatternMatching.Match match)
protected internal override bool DoMatch (AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match)
{
var o = other as FixedVariableInitializer;
return o != null && MatchString (this.Name, o.Name) && this.Initializer.DoMatch (o.Initializer, match);
return o != null && MatchString (this.Name, o.Name) && this.CountExpression.DoMatch (o.CountExpression, match);
}
}
}

38
ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/VariableInitializer.cs

@ -28,6 +28,42 @@ namespace ICSharpCode.NRefactory.CSharp @@ -28,6 +28,42 @@ namespace ICSharpCode.NRefactory.CSharp
{
public class VariableInitializer : AstNode
{
#region PatternPlaceholder
public static implicit operator VariableInitializer(PatternMatching.Pattern pattern)
{
return pattern != null ? new PatternPlaceholder(pattern) : null;
}
sealed class PatternPlaceholder : VariableInitializer, PatternMatching.INode
{
readonly PatternMatching.Pattern child;
public PatternPlaceholder(PatternMatching.Pattern child)
{
this.child = child;
}
public override NodeType NodeType {
get { return NodeType.Pattern; }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitPatternPlaceholder(this, child, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
return child.DoMatch(other, match);
}
bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo)
{
return child.DoMatchCollection(role, pos, match, backtrackingInfo);
}
}
#endregion
public override NodeType NodeType {
get {
return NodeType.Unknown;
@ -67,7 +103,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -67,7 +103,7 @@ namespace ICSharpCode.NRefactory.CSharp
return visitor.VisitVariableInitializer (this, data);
}
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.CSharp.PatternMatching.Match match)
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
VariableInitializer o = other as VariableInitializer;
return o != null && MatchString(this.Name, o.Name) && this.Initializer.DoMatch(o.Initializer, match);

18
ICSharpCode.NRefactory/CSharp/Formatter/AstFormattingVisitor.cs

@ -33,7 +33,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -33,7 +33,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
public class AstFormattingVisitor : DepthFirstAstVisitor<object, object>
{
CSharpFormattingPolicy policy;
CSharpFormattingOptions policy;
ITextEditorAdapter data;
List<Change> changes = new List<Change> ();
Indent curIndent = new Indent ();
@ -66,7 +66,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -66,7 +66,7 @@ namespace ICSharpCode.NRefactory.CSharp
set;
}
public AstFormattingVisitor (CSharpFormattingPolicy policy, ITextEditorAdapter data)
public AstFormattingVisitor (CSharpFormattingOptions policy, ITextEditorAdapter data)
{
this.policy = policy;
this.data = data;
@ -521,13 +521,25 @@ namespace ICSharpCode.NRefactory.CSharp @@ -521,13 +521,25 @@ namespace ICSharpCode.NRefactory.CSharp
{
FixIndentationForceNewLine (fieldDeclaration.StartLocation);
FormatCommas (fieldDeclaration, policy.SpaceBeforeFieldDeclarationComma, policy.SpaceAfterFieldDeclarationComma);
if (fieldDeclaration.NextSibling is FieldDeclaration) {
if (fieldDeclaration.NextSibling is FieldDeclaration || fieldDeclaration.NextSibling is FixedFieldDeclaration) {
EnsureBlankLinesAfter (fieldDeclaration, policy.BlankLinesBetweenFields);
} else if (IsMember (fieldDeclaration.NextSibling)) {
EnsureBlankLinesAfter (fieldDeclaration, policy.BlankLinesBetweenMembers);
}
return base.VisitFieldDeclaration (fieldDeclaration, data);
}
public override object VisitFixedFieldDeclaration (FixedFieldDeclaration fixedFieldDeclaration, object data)
{
FixIndentationForceNewLine (fixedFieldDeclaration.StartLocation);
FormatCommas (fixedFieldDeclaration, policy.SpaceBeforeFieldDeclarationComma, policy.SpaceAfterFieldDeclarationComma);
if (fixedFieldDeclaration.NextSibling is FieldDeclaration || fixedFieldDeclaration.NextSibling is FixedFieldDeclaration ) {
EnsureBlankLinesAfter (fixedFieldDeclaration, policy.BlankLinesBetweenFields);
} else if (IsMember (fixedFieldDeclaration.NextSibling)) {
EnsureBlankLinesAfter (fixedFieldDeclaration, policy.BlankLinesBetweenMembers);
}
return base.VisitFixedFieldDeclaration (fixedFieldDeclaration, data);
}
public override object VisitEnumMemberDeclaration (EnumMemberDeclaration enumMemberDeclaration, object data)
{

24
ICSharpCode.NRefactory/CSharp/Formatter/CSharpFormattingPolicy.cs → ICSharpCode.NRefactory/CSharp/Formatter/CSharpFormattingOptions.cs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// CSharpFormattingPolicy.cs
// CSharpFormattingOptions.cs
//
// Author:
// Mike Krüger <mkrueger@novell.com>
@ -60,7 +60,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -60,7 +60,7 @@ namespace ICSharpCode.NRefactory.CSharp
ForceNewLine
}
public class CSharpFormattingPolicy
public class CSharpFormattingOptions
{
public string Name {
get;
@ -72,9 +72,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -72,9 +72,9 @@ namespace ICSharpCode.NRefactory.CSharp
set;
}
public CSharpFormattingPolicy Clone ()
public CSharpFormattingOptions Clone ()
{
return (CSharpFormattingPolicy)MemberwiseClone ();
return (CSharpFormattingOptions)MemberwiseClone ();
}
#region Indentation
@ -766,7 +766,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -766,7 +766,7 @@ namespace ICSharpCode.NRefactory.CSharp
#endregion
public CSharpFormattingPolicy ()
public CSharpFormattingOptions ()
{
IndentNamespaceBody = true;
IndentClassBody = IndentInterfaceBody = IndentStructBody = IndentEnumBody = true;
@ -880,22 +880,22 @@ namespace ICSharpCode.NRefactory.CSharp @@ -880,22 +880,22 @@ namespace ICSharpCode.NRefactory.CSharp
BlankLinesBetweenMembers = 1;
}
/*public static CSharpFormattingPolicy Load (FilePath selectedFile)
/*public static CSharpFormattingOptions Load (FilePath selectedFile)
{
using (var stream = System.IO.File.OpenRead (selectedFile)) {
return Load (stream);
}
}
public static CSharpFormattingPolicy Load (System.IO.Stream input)
public static CSharpFormattingOptions Load (System.IO.Stream input)
{
CSharpFormattingPolicy result = new CSharpFormattingPolicy ();
CSharpFormattingOptions result = new CSharpFormattingOptions ();
result.Name = "noname";
using (XmlTextReader reader = new XmlTextReader (input)) {
while (reader.Read ()) {
if (reader.NodeType == XmlNodeType.Element) {
if (reader.LocalName == "Property") {
var info = typeof(CSharpFormattingPolicy).GetProperty (reader.GetAttribute ("name"));
var info = typeof(CSharpFormattingOptions).GetProperty (reader.GetAttribute ("name"));
string valString = reader.GetAttribute ("value");
object value;
if (info.PropertyType == typeof(bool)) {
@ -926,7 +926,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -926,7 +926,7 @@ namespace ICSharpCode.NRefactory.CSharp
writer.IndentChar = '\t';
writer.WriteStartElement ("FormattingProfile");
writer.WriteAttributeString ("name", Name);
foreach (PropertyInfo info in typeof (CSharpFormattingPolicy).GetProperties ()) {
foreach (PropertyInfo info in typeof (CSharpFormattingOptions).GetProperties ()) {
if (info.GetCustomAttributes (false).Any (o => o.GetType () == typeof(ItemPropertyAttribute))) {
writer.WriteStartElement ("Property");
writer.WriteAttributeString ("name", info.Name);
@ -938,9 +938,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -938,9 +938,9 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public bool Equals (CSharpFormattingPolicy other)
public bool Equals (CSharpFormattingOptions other)
{
foreach (PropertyInfo info in typeof (CSharpFormattingPolicy).GetProperties ()) {
foreach (PropertyInfo info in typeof (CSharpFormattingOptions).GetProperties ()) {
if (info.GetCustomAttributes (false).Any (o => o.GetType () == typeof(ItemPropertyAttribute))) {
object val = info.GetValue (this, null);
object otherVal = info.GetValue (other, null);

125
ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

@ -9,7 +9,7 @@ using System.IO; @@ -9,7 +9,7 @@ using System.IO;
using System.Linq;
using System.Text;
using ICSharpCode.NRefactory.CSharp.PatternMatching;
using ICSharpCode.NRefactory.PatternMatching;
using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.CSharp
@ -17,10 +17,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -17,10 +17,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// Outputs the AST.
/// </summary>
public class OutputVisitor : IPatternAstVisitor<object, object>
public class OutputVisitor : IAstVisitor<object, object>, IPatternAstVisitor<object, object>
{
readonly IOutputFormatter formatter;
readonly CSharpFormattingPolicy policy;
readonly CSharpFormattingOptions policy;
readonly Stack<AstNode> containerStack = new Stack<AstNode>();
readonly Stack<AstNode> positionStack = new Stack<AstNode>();
@ -42,7 +42,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -42,7 +42,7 @@ namespace ICSharpCode.NRefactory.CSharp
Division
}
public OutputVisitor(TextWriter textWriter, CSharpFormattingPolicy formattingPolicy)
public OutputVisitor(TextWriter textWriter, CSharpFormattingOptions formattingPolicy)
{
if (textWriter == null)
throw new ArgumentNullException("textWriter");
@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -52,7 +52,7 @@ namespace ICSharpCode.NRefactory.CSharp
this.policy = formattingPolicy;
}
public OutputVisitor(IOutputFormatter formatter, CSharpFormattingPolicy formattingPolicy)
public OutputVisitor(IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy)
{
if (formatter == null)
throw new ArgumentNullException("formatter");
@ -67,7 +67,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -67,7 +67,7 @@ namespace ICSharpCode.NRefactory.CSharp
{
// Ensure that nodes are visited in the proper nested order.
// Jumps to different subtrees are allowed only for the child of a placeholder node.
Debug.Assert(containerStack.Count == 0 || node.Parent == containerStack.Peek() || containerStack.Peek().NodeType == NodeType.Placeholder);
Debug.Assert(containerStack.Count == 0 || node.Parent == containerStack.Peek() || containerStack.Peek().NodeType == NodeType.Pattern);
if (positionStack.Count > 0)
WriteSpecialsUpToNode(node);
containerStack.Push(node);
@ -468,15 +468,29 @@ namespace ICSharpCode.NRefactory.CSharp @@ -468,15 +468,29 @@ namespace ICSharpCode.NRefactory.CSharp
return EndNode(anonymousMethodExpression);
}
public object VisitArgListExpression(ArgListExpression argListExpression, object data)
{
StartNode(argListExpression);
WriteKeyword("__arglist");
if (!argListExpression.IsAccess) {
public object VisitUndocumentedExpression(UndocumentedExpression undocumentedExpression, object data)
{
StartNode(undocumentedExpression);
switch (undocumentedExpression.UndocumentedExpressionType) {
case UndocumentedExpressionType.ArgList:
case UndocumentedExpressionType.ArgListAccess:
WriteKeyword("__arglist");
break;
case UndocumentedExpressionType.MakeRef:
WriteKeyword("__makeref");
break;
case UndocumentedExpressionType.RefType:
WriteKeyword("__reftype");
break;
case UndocumentedExpressionType.RefValue:
WriteKeyword("__refvalue");
break;
}
if (undocumentedExpression.Arguments.Count > 0) {
Space(policy.SpaceBeforeMethodCallParentheses);
WriteCommaSeparatedListInParenthesis(argListExpression.Arguments, policy.SpaceWithinMethodCallParentheses);
WriteCommaSeparatedListInParenthesis(undocumentedExpression.Arguments, policy.SpaceWithinMethodCallParentheses);
}
return EndNode(argListExpression);
return EndNode(undocumentedExpression);
}
public object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
@ -501,7 +515,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -501,7 +515,7 @@ namespace ICSharpCode.NRefactory.CSharp
style = BraceStyle.EndOfLine;
OpenBrace(style);
bool isFirst = true;
foreach (AstNode node in arrayInitializerExpression.Children) {
foreach (AstNode node in arrayInitializerExpression.Elements) {
if (isFirst) {
isFirst = false;
} else {
@ -771,6 +785,25 @@ namespace ICSharpCode.NRefactory.CSharp @@ -771,6 +785,25 @@ namespace ICSharpCode.NRefactory.CSharp
return EndNode(objectCreateExpression);
}
public object VisitAnonymousTypeCreateExpression(AnonymousTypeCreateExpression anonymousTypeCreateExpression, object data)
{
StartNode(anonymousTypeCreateExpression);
WriteKeyword("new");
Space();
LPar();
RPar();
Space();
OpenBrace(policy.AnonymousMethodBraceStyle);
foreach (AstNode node in anonymousTypeCreateExpression.Initializer) {
node.AcceptVisitor(this, null);
if (node.NextSibling != null)
Comma(node);
NewLine ();
}
CloseBrace(policy.AnonymousMethodBraceStyle);
return EndNode(anonymousTypeCreateExpression);
}
public object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data)
{
StartNode(parenthesizedExpression);
@ -1026,7 +1059,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1026,7 +1059,8 @@ namespace ICSharpCode.NRefactory.CSharp
if (first) {
first = false;
} else {
NewLine();
if (!(clause is QueryContinuationClause))
NewLine();
}
clause.AcceptVisitor(this, data);
}
@ -1169,8 +1203,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1169,8 +1203,8 @@ namespace ICSharpCode.NRefactory.CSharp
{
StartNode(attributeSection);
WriteToken("[", AstNode.Roles.LBracket);
if (attributeSection.AttributeTarget != AttributeTarget.None) {
WriteToken(AttributeSection.GetAttributeTargetName(attributeSection.AttributeTarget), AttributeSection.TargetRole);
if (!string.IsNullOrEmpty (attributeSection.AttributeTarget)) {
WriteToken(attributeSection.AttributeTarget, AttributeSection.TargetRole);
WriteToken(":", AttributeSection.Roles.Colon);
Space();
}
@ -1847,7 +1881,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1847,7 +1881,6 @@ namespace ICSharpCode.NRefactory.CSharp
StartNode(fixedFieldDeclaration);
WriteAttributes(fixedFieldDeclaration.Attributes);
WriteModifiers(fixedFieldDeclaration.ModifierTokens);
Space();
WriteKeyword("fixed");
Space();
fixedFieldDeclaration.ReturnType.AcceptVisitor (this, data);
@ -1861,10 +1894,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1861,10 +1894,10 @@ namespace ICSharpCode.NRefactory.CSharp
{
StartNode(fixedVariableInitializer);
WriteIdentifier(fixedVariableInitializer.Name);
if (!fixedVariableInitializer.Initializer.IsNull) {
if (!fixedVariableInitializer.CountExpression.IsNull) {
WriteToken("[", AstNode.Roles.LBracket);
Space(policy.SpacesWithinBrackets);
fixedVariableInitializer.Initializer.AcceptVisitor(this, data);
fixedVariableInitializer.CountExpression.AcceptVisitor(this, data);
Space(policy.SpacesWithinBrackets);
WriteToken("]", AstNode.Roles.RBracket);
}
@ -2140,77 +2173,71 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2140,77 +2173,71 @@ namespace ICSharpCode.NRefactory.CSharp
#endregion
#region Pattern Nodes
object IPatternAstVisitor<object, object>.VisitPlaceholder(AstNode placeholder, AstNode child, object data)
public object VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, object data)
{
StartNode(placeholder);
child.AcceptVisitor(this, data);
pattern.AcceptVisitor(this, data);
return EndNode(placeholder);
}
object IPatternAstVisitor<object, object>.VisitAnyNode(AnyNode anyNode, object data)
{
StartNode(anyNode);
if (!string.IsNullOrEmpty(anyNode.GroupName)) {
WriteIdentifier(anyNode.GroupName);
WriteToken(":", AstNode.Roles.Colon);
}
WriteKeyword("anyNode");
return EndNode(anyNode);
return null;
}
object IPatternAstVisitor<object, object>.VisitBackreference(Backreference backreference, object data)
{
StartNode(backreference);
WriteKeyword("backreference");
LPar();
WriteIdentifier(backreference.ReferencedGroupName);
RPar();
return EndNode(backreference);
return null;
}
object IPatternAstVisitor<object, object>.VisitIdentifierExpressionBackreference(IdentifierExpressionBackreference identifierExpressionBackreference, object data)
{
StartNode(identifierExpressionBackreference);
WriteKeyword("identifierBackreference");
LPar();
WriteIdentifier(identifierExpressionBackreference.ReferencedGroupName);
RPar();
return EndNode(identifierExpressionBackreference);
return null;
}
object IPatternAstVisitor<object, object>.VisitChoice(Choice choice, object data)
{
StartNode(choice);
WriteKeyword("choice");
Space();
LPar();
NewLine();
formatter.Indent();
foreach (AstNode alternative in choice) {
alternative.AcceptVisitor(this, data);
if (alternative != choice.LastChild)
foreach (INode alternative in choice) {
VisitNodeInPattern(alternative, data);
if (alternative != choice.Last())
WriteToken(",", AstNode.Roles.Comma);
NewLine();
}
formatter.Unindent();
RPar();
return EndNode(choice);
return null;
}
object IPatternAstVisitor<object, object>.VisitNamedNode(NamedNode namedNode, object data)
{
StartNode(namedNode);
if (!string.IsNullOrEmpty(namedNode.GroupName)) {
WriteIdentifier(namedNode.GroupName);
WriteToken(":", AstNode.Roles.Colon);
}
namedNode.GetChildByRole(NamedNode.ElementRole).AcceptVisitor(this, data);
return EndNode(namedNode);
VisitNodeInPattern(namedNode.ChildNode, data);
return null;
}
object IPatternAstVisitor<object, object>.VisitRepeat(Repeat repeat, object data)
{
StartNode(repeat);
WriteKeyword("repeat");
LPar();
if (repeat.MinCount != 0 || repeat.MaxCount != int.MaxValue) {
@ -2219,19 +2246,33 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2219,19 +2246,33 @@ namespace ICSharpCode.NRefactory.CSharp
WriteIdentifier(repeat.MaxCount.ToString());
WriteToken(",", AstNode.Roles.Comma);
}
repeat.GetChildByRole(Repeat.ElementRole).AcceptVisitor(this, data);
VisitNodeInPattern(repeat.ChildNode, data);
RPar();
return EndNode(repeat);
return null;
}
object IPatternAstVisitor<object, object>.VisitOptionalNode(OptionalNode optionalNode, object data)
{
StartNode(optionalNode);
WriteKeyword("optional");
LPar();
optionalNode.GetChildByRole(OptionalNode.ElementRole).AcceptVisitor(this, data);
VisitNodeInPattern(optionalNode.ChildNode, data);
RPar();
return EndNode(optionalNode);
return null;
}
void VisitNodeInPattern(INode childNode, object data)
{
AstNode astNode = childNode as AstNode;
if (astNode != null) {
astNode.AcceptVisitor(this, data);
} else {
Pattern pattern = childNode as Pattern;
if (pattern != null) {
pattern.AcceptVisitor(this, data);
} else {
throw new InvalidOperationException("Unknown node type in pattern");
}
}
}
#endregion
}

696
ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs

File diff suppressed because it is too large Load Diff

8
ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs

@ -308,8 +308,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -308,8 +308,8 @@ namespace ICSharpCode.NRefactory.CSharp
ConvertTypeParameters(m.TypeParameters, methodDeclaration.TypeParameters, methodDeclaration.Constraints);
m.ReturnType = ConvertType(methodDeclaration.ReturnType);
ConvertAttributes(m.Attributes, methodDeclaration.Attributes.Where(s => s.AttributeTarget != AttributeTarget.Return));
ConvertAttributes(m.ReturnTypeAttributes, methodDeclaration.Attributes.Where(s => s.AttributeTarget == AttributeTarget.Return));
ConvertAttributes(m.Attributes, methodDeclaration.Attributes.Where(s => s.AttributeTarget != "return"));
ConvertAttributes(m.ReturnTypeAttributes, methodDeclaration.Attributes.Where(s => s.AttributeTarget == "return"));
ApplyModifiers(m, methodDeclaration.Modifiers);
m.IsExtensionMethod = methodDeclaration.IsExtensionMethod;
@ -346,8 +346,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -346,8 +346,8 @@ namespace ICSharpCode.NRefactory.CSharp
m.BodyRegion = MakeRegion(operatorDeclaration.Body);
m.ReturnType = ConvertType(operatorDeclaration.ReturnType);
ConvertAttributes(m.Attributes, operatorDeclaration.Attributes.Where(s => s.AttributeTarget != AttributeTarget.Return));
ConvertAttributes(m.ReturnTypeAttributes, operatorDeclaration.Attributes.Where(s => s.AttributeTarget == AttributeTarget.Return));
ConvertAttributes(m.Attributes, operatorDeclaration.Attributes.Where(s => s.AttributeTarget != "return"));
ConvertAttributes(m.ReturnTypeAttributes, operatorDeclaration.Attributes.Where(s => s.AttributeTarget == "return"));
ApplyModifiers(m, operatorDeclaration.Modifiers);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save