in RuleSamples/CapitalizedNamesRule.cs [114:140]
private void CheckIfCapitalized(TSqlObject tSqlObject, List<SqlRuleProblem> problems)
{
ObjectIdentifier name = tSqlObject.Name;
if (name != null
&& name.HasName
&& name.Parts.Count > 0) // This check is equivalent to name.HasHame, including in case you don't trust the framework and want to verify yourself
{
string actualName = name.Parts[name.Parts.Count - 1];
if (!string.IsNullOrEmpty(actualName)
&& Char.IsLetterOrDigit(actualName[0])
&& !Char.IsUpper(actualName[0]))
{
string description = string.Format(CultureInfo.CurrentCulture,
RuleResources.CapitalizedNames_ProblemDescription,
_model.DisplayServices.GetElementName(tSqlObject, ElementNameStyle.EscapedFullyQualifiedName));
// Name fragment would have more precise location information than the overall object.
// This can be null, in which case the object's position will be used.
// note that the current implementation does not work for non-top level types as it
// relies on the TSqlModelUtils.TryGetFragmentForAnalysis() method which doesn't support these.
TSqlFragment nameFragment = TsqlScriptDomUtils.LookupSchemaObjectName(tSqlObject);
problems.Add(new SqlRuleProblem(description, tSqlObject, nameFragment));
}
}
}