Skip to content

Commit

Permalink
Fix for #59. Added support for nameof operator.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyTeplyakov committed Sep 28, 2015
1 parent cbc81fc commit beb584e
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,22 @@ public static bool IsValidForRequires(this Message message)

return Match(message, _ => true, // string literals are valid
r => IsValidReference(r.Reference), // references should be checked separately
_ => false, // message calls are invalid
i => IsValidInvocation(i.InvocationExpression), // message calls are invalid
() => true); // "NoMessage" is valid

}

private static bool IsValidInvocation(IInvocationExpression invocationExpression)
{
// Supper naive an hacky way of checking for nameof:
if (invocationExpression.GetText().StartsWith("nameof(", StringComparison.InvariantCulture))
{
return true;
}

return false;
}

/// <summary>
/// Returns true if <paramref name="referenceExpression"/> points to the static field or property
/// with at least internal access.
Expand Down

0 comments on commit beb584e

Please sign in to comment.