public void DelegateSyntax_GetIdentifier(string delegateName, bool isGeneric, string expectedResult) { TypeDef testDelegate = GetDelegateFromTestAssembly(); DelegateSyntax syntax = new DelegateSyntax(testDelegate); testDelegate.Name = delegateName; testDelegate.IsGeneric = isGeneric; string result = syntax.GetIdentifier(); Assert.AreEqual(expectedResult, result); }
public SyntaxTokenCollection Format(DelegateSyntax syntax) { SyntaxTokenCollection tokens = new SyntaxTokenCollection(); tokens.AddRange(FormatVisibility(syntax)); tokens.Add(Constants.Space); tokens.Add(Constants.KeywordDelegate); tokens.Add(Constants.Space); tokens.AddRange(FormatReturnType(syntax)); tokens.Add(Constants.Space); tokens.Add(new SyntaxToken(syntax.GetIdentifier(), SyntaxTokens.Text)); if (_syntax.Class.IsGeneric) { List <GenericTypeRef> genericTypes = _syntax.GetGenericParameters(); tokens.AddRange(FormatGenericParameters(genericTypes)); } tokens.AddRange(FormatParameters(syntax.Method)); return(tokens); }
public SyntaxTokenCollection Format(DelegateSyntax syntax) { SyntaxTokenCollection tokens = new SyntaxTokenCollection(); tokens.AddRange(FormatVisibility(syntax)); tokens.Add(Constants.Space); tokens.Add(new SyntaxToken("Delegate", SyntaxTokens.Keyword)); tokens.Add(Constants.Space); if (IsMethodFunction(syntax.GetReturnType())) { tokens.Add(Constants.KeywordFunction); } else { tokens.Add(Constants.KeywordSub); } tokens.Add(Constants.Space); tokens.Add(new SyntaxToken(syntax.GetIdentifier(), SyntaxTokens.Text)); tokens.AddRange(FormatParameters(syntax.Method)); // Add the generic details of the delegate if (_syntax.Class.IsGeneric) { List <GenericTypeRef> genericTypes = _syntax.GetGenericParameters(); tokens.AddRange(FormatGenericParameters(genericTypes)); } if (this.IsMethodFunction(syntax.GetReturnType())) { tokens.Add(Constants.Space); tokens.Add(Constants.KeywordAs); tokens.Add(Constants.Space); tokens.AddRange(FormatReturnType(syntax)); } return(tokens); }
public CSharpDelegateFormatter(DelegateSyntax syntax) { _syntax = syntax; }
public List <SyntaxToken> FormatReturnType(DelegateSyntax syntax) { return(FormatTypeDetails(syntax.GetReturnType())); }
public List <SyntaxToken> FormatVisibility(DelegateSyntax syntax) { return(FormatVisibility(syntax.GetVisibility())); }
public VBDelegateFormatter(DelegateSyntax syntax) { _syntax = syntax; }