Enable TreatErrorsAsWarnings for particular violation codes (like SA0001)

Feb 7, 2013 at 6:22 PM
MsBuild.

I have TreatErrorsAsWarnings=false so that any violation breaks the build. However on some sources I get SA0001 due to internal StyleCop bugs. In this case it should be warning, not error.

How I can do it?
Feb 15, 2013 at 5:51 PM
I ended up writing my own MsBuild task which is copy/paste of StyleCop's original task with some customization.
Coordinator
Feb 15, 2013 at 5:53 PM
Attach it and i will review it and merge it in


~Andy.

On 15 Feb 2013, at 20:52, abibok <notifications@codeplex.com> wrote:

From: abibok

I ended up writing my own MsBuild task which is copy/paste of StyleCop's original task with some customization.
Feb 15, 2013 at 6:19 PM
StyleCopTask.cs is too long to insert it as code in reply message. How I can attach it as file?

These are the changes:
Line 36:
        /// <summary>
        /// Internal StyleCop violation codes that should not be treated as error level violations.
        /// </summary>
        private static readonly string[] InternalStyleCopErrors = { "SA0001", "SA0100", "SA0101", "SA0102" };

Line 450:
            if (InternalStyleCopErrors.Contains(e.Violation.Rule.CheckId))
            {
                base.Log.LogMessage(
                    MessageImportance.High,
                    "StyleCop internal error {0}:\n{1}",
                    e.Violation.Rule.CheckId,
                    e.Violation.Message);

                return;
            }