C# 如何将console.OutputGenerated转换为字符串并打印

C# 如何将console.OutputGenerated转换为字符串并打印,c#,nunit,stylecop,C#,Nunit,Stylecop,我正在尝试将console.OutputGenerated转换为字符串,并希望转换为console.writeline(“打印错误”),寻求如何执行此操作的建议。下面是我的代码 public void TestMain() { string projectPath = @"C:\Documents and Settings\NickyPhun\My Documents\Visual Studio 2010\Projects\MyCustomRules3\MyCustomR

我正在尝试将console.OutputGenerated转换为字符串,并希望转换为console.writeline(“打印错误”),寻求如何执行此操作的建议。下面是我的代码

public void TestMain()
    {
        string projectPath = @"C:\Documents and Settings\NickyPhun\My Documents\Visual Studio 2010\Projects\MyCustomRules3\MyCustomRules3";
        string filePath = @"C:\Documents and Settings\NickyPhun\My Documents\Visual Studio 2010\Projects\MyCustomRules3\MyCustomRules3\MyCustomRules3.cs";

        StyleCopConsole console = new StyleCopConsole(null, false, null, null, true);

        CodeProject project = new CodeProject(0, projectPath, new Configuration(null));

        console.Core.Environment.AddSourceCode(project, filePath, null);
        console.OutputGenerated += OnOutputGenerated;
        console.ViolationEncountered += OnViolationEncountered;
        console.Start(new[] { project }, true);
        console.OutputGenerated -= OnOutputGenerated;
        console.ViolationEncountered -= OnViolationEncountered;

    }

    public void OnOutputGenerated(object sender, OutputEventArgs e)
    {
        Console.WriteLine(e.Output);

    }

总体而言,你想要完成什么?你的目标是什么?嗨@Bernard,我正试图在NUnit文本输出上显示stylecop v4.7自定义规则。正在寻找这方面的专家:D