jwaliszko / ExpressiveAnnotations

Annotation-based conditional validation library.
MIT License
351 stars 123 forks source link

RequiredIf rule suddenly requiring full namespace #209

Open ssteiner opened 3 years ago

ssteiner commented 3 years ago

We've been using ExpressiveAnnotations for a while now to validate data in our backend models and for an MVC FE.

We can't quite put the finger on when this started happening (it's a rather infrequently used model), but all of a sudden, we're getting expressions from some of our RequiredIf tags. The issue is that an enum type exists in two namespaces. That's easily fixed by prefixing the namespace, yet that now causes issues in our new FE (we're translating the Expressive Annotations syntax into the syntax required by our new FE- the new FE is not C# so it's not namespace aware).

What I don't quite get... the library that contains our models, it's self-contained with zero dependencies. The using statements in the class that causes problems just includes ExpressiveAnnotations.Attributes and System.ComponentModel.DataAnnotations.

Why would ExpressiveAnnotations perform a global type search and not just look at what the project that makes use of the the data annotations?

the context of our solution is 60+ projects, that means a ton of namespaces and types. Shouldn't a type search be more contrained and only check the current namespace plus perhaps whatever's included in the class at hand (using the using statements)?