/// <summary> /// Formats the provided <paramref name="syntax"/> instance based on a /// c# class decleration. /// </summary> /// <param name="syntax">The syntax for format.</param> /// <returns>A fully formatted c# class decleration.</returns> public SyntaxTokenCollection Format(ClassSyntax syntax) { SyntaxTokenCollection tokens = new SyntaxTokenCollection(); SyntaxToken inheritanceModifier = FormatInheritance(syntax); tokens.AddRange(FormatVisibility(syntax)); if (inheritanceModifier != null) { tokens.Add(Constants.Space); tokens.Add(inheritanceModifier); } tokens.Add(Constants.Space); tokens.Add(Constants.KeywordClass); 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(FormatClassBase(syntax)); return(tokens); }
public void ClassSyntax_GetIdentifier(string name, bool isGeneric, string expectedResult) { TypeDef typeDef = new TypeDef(); ClassSyntax syntax = new ClassSyntax(typeDef); typeDef.IsGeneric = isGeneric; typeDef.Name = name; string result = syntax.GetIdentifier(); Assert.AreEqual(expectedResult, result); }