Добавьте файлы проекта.
This commit is contained in:
28
SQLLinter/Infrastructure/Rules/UnicodeStringRule.cs
Normal file
28
SQLLinter/Infrastructure/Rules/UnicodeStringRule.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Microsoft.SqlServer.TransactSql.ScriptDom;
|
||||
using SQLLinter.Common;
|
||||
using SQLLinter.Common.Helpers;
|
||||
|
||||
namespace SQLLinter.Infrastructure.Rules;
|
||||
|
||||
public class UnicodeStringRule : BaseRuleVisitor, IRule
|
||||
{
|
||||
public override string Text => "Использование символов Юникода в строке, отличной от Юникода";
|
||||
|
||||
public override void Visit(StringLiteral node)
|
||||
{
|
||||
if (node.IsNational)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsAscii(node.Value))
|
||||
{
|
||||
AddViolation(Name, Text, node.StartLine, node.StartColumn);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsAscii(string part)
|
||||
{
|
||||
return SQLHelpers.IsValidForEncoding(part, "windows-1251");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user