visual-studiocode-generationcode-analysissqlmetal

Ignore Code Analysis for SqlMetal generated files


I'm developing a C# project which includes a SqlMetal generated file. I'd like to use Code Analysis. I've turned on "Suppress results from generated code" in the Code Analysis options, but it still reports on the SqlMetal classes. Is there some way to turn this off?

I'm using Visual Studio 2008 and SqlMetal 2.0.50727.3082


Solution

  • One option is to edit the generated source to simply add "partial" to the classes you care about.

    Then you can add in a separate file(s)

    [GeneratedCode]
    public partial class Foo
    {
    }
    

    for every class Foo you made partial

    Then the worst that can happen on regeneration is that the partial link becomes broken (which will result in a compile error so you know that this has happened and needs correcting (simply and easily).

    I would also suggest you file a connect bug/request asking for them to add this attribute generation as an option on sql metal itself.