Fix: Spreading versioned models - #441
Conversation
|
I feel like we need to support libraries which allow versioning in the context of their own versions (so if we have a dependency on D2 we spread only D2 properties) and spread in the context of local versions (so if we pass L1 to an abstraction, the properties that it adds are added in L1). I think the only way this can work is if we pass versions as enum member references rather than strings, and this cleans up a lot of the logic around determining which versions are applicable. If we had such a mechanism, do you think this PR would be necessary or different? |
|
Brian Terlson (@bterlson) I commented on this on the issue, I think it solve the problem 1 and would definitly cleanup a lot of code. But for the 2nd one the issue is not that we don't know what are the versions for the type but that we don't know which version we should use for that property which is why I made this version mapping. |
|
You can try these changes at https://cadlplayground.z22.web.core.windows.net/prs/441/ |
fix #244
fix #320
Problems
1. Using versioning in model expression and/or with spread
Model expression didn't have a reference of which namespace they were defined in which prevent the verisoning lib to know which were the available version for those models
Library model that spread a model from another versioned namespace
The issue here is also that the property
bis included in this instanceVersionedLib.Spread<Spreadable>when running the projection "1" despite the property being added in version "2".The problem here is that when the versioning projection run on
VersionedLib.Spread<Spreadable>it is then using the versionl1as this is part of theVersionedLibscope.Now when it comes time to resolve if property
bshould be included or not the version library check if the proeprty is available in versionl1instead of "1" which it of course cannot find and so assume the property should be included.Solution
A tentative to fix spreading versioned model.
Changes:
Let me know what you think
Things to cleanup: