Permanent warning in a generated module class

Mikhail Dervel asked on February 14, 2020 10:41

Hi! We have a custom module with classes and all of them have warning directive in a generated code above TYPEINFO definition :

#warning "You will need to configure the type info."

I guess it's like a pointer to a place where you can specify your own properties for that custom class, but how can I disable generating of this warning?

Recent Answers


Dat Nguyen answered on February 14, 2020 11:27 (last edited on February 14, 2020 11:52)

There doesn't appear to be a way to prevent the code generator from including the warning.

Intellisense should help you suppress the warning with a #pragma warning directive, but in case it doesn't, here's what it looks like to add the directive manually:

    #pragma warning disable CS1030 // #warning directive
    #warning "You will need to configure the type info."
    public static readonly ObjectTypeInfo TYPEINFO = new ObjectTypeInfo(yada yada yada)
    #pragma warning restore CS1030 // #warning directive
    {
        ModuleName = "whatevs",
        TouchCacheDependencies = true,
    };
0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on February 14, 2020 20:07 (last edited on February 14, 2020 20:53)

What it says is that you have to configure your TypeInfo for import/export operations. If you are not planning to do import/export your classes you can just ignore that. See the documentation

0 votesVote for this answer Mark as a Correct answer

Mikhail Dervel answered on February 17, 2020 11:33

Peter, thank you for explanation! However, what if I don't want have got warnings in my project? It seems like I should always delete wring row manually after another rendering

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on February 17, 2020 19:05

Do not delete, you may try to comment it and give explanation and link in the comment.But it might not work. If you don't really want to have warning - I'd day - configure it! It is not so complicated as it might seem. Follow the example and you ll be fine.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.