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?

Correct Answer

Peter Mogilnitski answered on February 14, 2020 20:07

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 Unmark Correct answer

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

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.

1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 19, 2020 16:50

It's not that big of a deal. Delete the comment line and move on. It's there to simply tell you to configure the TypeInfo from the automaticaly generated class code.

Unfortunately, the base template for the classes is baked into the source code of Kentico so unless you have a sourcecode license, you won't see or be able to edit that template.

1 votesVote for this answer Mark as a Correct answer

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