513错误代码(退出代码)FxCop使用C#

513错误代码(退出代码)FxCop使用C#,c#,fxcop,exit-code,error-code,fxcopcmd,C#,Fxcop,Exit Code,Error Code,Fxcopcmd,我有VS2010,Windows 7位,FxCop 10.0 我使用Process.Start执行Fxcopcmd.exe,得到513“exitcode”(错误代码)值 托德·金在下面的参考资料中说: 在这种情况下,退出代码513表示FxCop有分析错误 (0x01)和程序集引用错误(0x200) 我想如果是 [Flags] public enum FxCopErrorCodes { NoErrors = 0x0, AnalysisErr

我有VS2010,Windows 7位,FxCop 10.0

我使用Process.Start执行Fxcopcmd.exe,得到513“exitcode”(错误代码)值

托德·金在下面的参考资料中说:

在这种情况下,退出代码513表示FxCop有分析错误 (0x01)和程序集引用错误(0x200)

我想如果是

    [Flags]
    public enum FxCopErrorCodes
    {
        NoErrors = 0x0,
        AnalysisError = 0x1,  // -fatalerror
        RuleExceptions = 0x2,
        ProjectLoadError = 0x4,
        AssemblyLoadError = 0x8,
        RuleLibraryLoadError = 0x10,
        ImportReportLoadError = 0x20,
        OutputError = 0x40,
        CommandlineSwitchError = 0x80,
        InitializationError = 0x100,
        AssemblyReferencesError = 0x200,
        BuildBreakingMessage = 0x400,
        UnknownError = 0x1000000,
    }
513整数值为0x201(视图和)

如何仅使用exitcode(513,0x201)值以编程方式了解错误(分析错误(0x01)和程序集引用错误(0x200)

有关FxCopCmd错误代码和代码分析的更多信息:


您可以使用AND和位操作测试枚举的特定值:

FxCopErrorCodes code = (FxCopErrorCodes)0x201;
if ((code & FxCopErrorCodes.InitializationError) == FxCopErrorCodes.InitializationError)
{
    Console.WriteLine("InitializationError");
}
您可以使用以下方法获得整个值列表:

private static IEnumerable<FxCopErrorCodes> GetMatchingValues(FxCopErrorCodes enumValue)
{
    // Special case for 0, as it always match using the bitwise AND operation
    if (enumValue == 0)
    {
        yield return FxCopErrorCodes.NoErrors;
    }

    // Gets list of possible values for the enum
    var values = Enum.GetValues(typeof(FxCopErrorCodes)).Cast<FxCopErrorCodes>();

    // Iterates over values and return those that match
    foreach (var value in values)
    {
        if (value > 0 && (enumValue & value) == value)
        {
            yield return value;
        }
    }
}
私有静态IEnumerable GetMatchingValues(FxCopErrorCodes enumValue)
{
//0的特殊情况,因为它总是使用按位AND运算进行匹配
如果(枚举值==0)
{
收益返回FxCopErrorCodes.NoErrors;
}
//获取枚举的可能值列表
var values=Enum.GetValues(typeof(FxCopErrorCodes)).Cast();
//迭代值并返回匹配的值
foreach(值中的var值)
{
如果(值>0&&(枚举值和值)==值)
{
收益回报值;
}
}
}

可能有用@Kiquenet它适用于3.5及以上版本。您必须使用System.Linq添加
。看见