11 changed files with 91 additions and 12 deletions
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// 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.Reflection; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp |
||||
{ |
||||
[TestFixture] |
||||
public class AstStructureTest |
||||
{ |
||||
[Test] |
||||
public void RolesAreStaticReadOnly() |
||||
{ |
||||
foreach (Type type in typeof(AstNode).Assembly.GetExportedTypes()) { |
||||
if (type.IsSubclassOf(typeof(AstNode))) { |
||||
foreach (FieldInfo field in type.GetFields()) { |
||||
if (field.FieldType.IsSubclassOf(typeof(Role))) { |
||||
Assert.IsTrue(field.IsPublic); |
||||
Assert.IsTrue(field.IsStatic); |
||||
Assert.IsTrue(field.IsInitOnly); |
||||
Assert.IsTrue(field.Name.EndsWith("Role", StringComparison.Ordinal)); |
||||
Assert.IsNotNull(field.GetValue(null)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.NRefactory.CSharp |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a named argument passed to a method or attribute.
|
||||
/// </summary>
|
||||
public class NamedArgumentExpression : Expression |
||||
{ |
||||
public string Identifier { |
||||
get { |
||||
return GetChildByRole (Roles.Identifier).Name; |
||||
} |
||||
set { |
||||
SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); |
||||
} |
||||
} |
||||
|
||||
public Expression Expression { |
||||
get { return GetChildByRole (Roles.Expression); } |
||||
set { SetChildByRole (Roles.Expression, value); } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(AstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitNamedArgumentExpression(this, data); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue