Skip to content

Instantly share code, notes, and snippets.

@EIrwin
Created November 7, 2014 21:39
Show Gist options
  • Save EIrwin/8b23583da3a7c6fb4449 to your computer and use it in GitHub Desktop.
Save EIrwin/8b23583da3a7c6fb4449 to your computer and use it in GitHub Desktop.
AnalyzeSymbol Method Implementation
public void AnalyzeSymbol(ISymbol symbol, Compilation compilation, Action<Diagnostic> addDiagnostic, CancellationToken cancellationToken)
{
var methodSymbol = (IMethodSymbol)symbol;
//Check if any method parameters are of type IInternalUser
if (methodSymbol.Parameters.Any(p => p.Type.Name.Contains("IInternalUser")))
{
var paramter = methodSymbol.Parameters.First();
//Check if IInerternalUser type is first parameter and there is more than one expected parameters
if (!paramter.Type.Name.Contains("IInternalUser") && methodSymbol.Parameters.Count() > 1)
{
var diagnostic = Diagnostic.Create(Rule, methodSymbol.Locations[0], methodSymbol.Name);
addDiagnostic(diagnostic);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment