Closed ryanlewis closed 2 years ago
Another possibility maybe just to add a #pragma
(might be 0108) directive to kill the compiler warnings.
So... the partial would look like...
[HidesInherited("myProperty")]
public partial class MyModel
{ }
And then we would generate either the new
keyword, or a proper #pragma
, so that the compiler does not raise a warning - and it has to be explicit because we cannot let you replace existing properties without even beeing aware of it.
Making sense?
Yep, something like that is exactly what I'm thinking - making perfect sense to me.
Request for comment:
[GeneratePropertyType("content", AsNew = true)]
public partial class MyContent
{ ... }
Would add the new
keyword to the Content
property so it does not conflict with the inherited propery. Could also be used for other IPublishedContent
properties such as sortOrder, index... obviously, you'd use at your own risk ;-)
Works just as well, possibly even better instead of another attribute to document. 👍
Note: implemented in a work-in-progress branch, to be part of the "next" major.
Minor issue here, maybe a
wontfix
, but thought I'd jot this down.Essentially, I have a property called "Content" on my document. This is less than ideal knowing the API, but ModelsBuilder generates a property for it and everything works as expected for now (may possibly break some third-party components, but haven't encountered any issues myself). The compiler complains with the warning below however.
Maybe allow an attribute to be added to the partial impl of the class to instruct the models builder to use the
new
keyword in instances like this, to avoid compiler errors? This way you have to be explicit to enable this behaviour.