個人的には、抑制を手動で (2 時間後に) 最新の状態に保つことにうんざりしていたので、次の T4 テンプレートを作成しました。
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Runtime.Remoting.Messaging" #>
<#@ output extension=".cs" #>
using System.Diagnostics.CodeAnalysis;
<#
var @namespace = CallContext.LogicalGetData("NamespaceHint");
var folder = Path.GetDirectoryName(Host.TemplateFile);
const int timestampLength = 15;
var timestampWildcards = new string('?', timestampLength);
var paths = Directory.EnumerateFiles(folder, timestampWildcards + "_*.cs");
const int timestampUnderscoreLength = timestampLength + 1;
var classNames = from path in paths
let fileName = Path.GetFileNameWithoutExtension(path)
where !fileName.EndsWith(".designer", StringComparison.OrdinalIgnoreCase)
where fileName.Length> timestampUnderscoreLength
select fileName.Substring(timestampUnderscoreLength);
foreach(var className in classNames)
{
var fullClassName = @namespace + "." + className;
#>
[assembly: SuppressMessage("Microsoft.Naming", "CA1701:ResourceStringCompoundWordsShouldBeCasedCorrectly", Scope = "resource", Target = "<#=fullClassName#>.resources")]
[assembly: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", Scope = "resource", Target = "<#=fullClassName#>.resources")]
<#
}
#>
このコンテンツを含む T4 テンプレートを移行と同じフォルダーに作成します。生成されたコードには、リソースの抑制が自動的に含まれます。
[assembly: SuppressMessage("Microsoft.Naming", "CA1701:ResourceStringCompoundWordsShouldBeCasedCorrectly", Scope = "resource", Target = "LzSoftware.Collectables.Domain.EntityFramework.Migrations.InitialCreation.resources")]
[assembly: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", Scope = "resource", Target = "LzSoftware.Collectables.Domain.EntityFramework.Migrations.InitialCreation.resources")]
[assembly: SuppressMessage("Microsoft.Naming", "CA1701:ResourceStringCompoundWordsShouldBeCasedCorrectly", Scope = "resource", Target = "LzSoftware.Collectables.Domain.EntityFramework.Migrations.RemovedAdministratorRoleFromSettings.resources")]
[assembly: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", Scope = "resource", Target = "LzSoftware.Collectables.Domain.EntityFramework.Migrations.RemovedAdministratorRoleFromSettings.resources")]