-
Notifications
You must be signed in to change notification settings - Fork 217
Description
Category
- Bug
Describe the bug
I described the bug over here because I initially thought this is an error in the provisioning engine -> pnp/pnpframework#716
Steps to reproduce
Not sure ^^. But see pnp/pnpframework#716 for more text.
Expected behavior
I expect VerifyProperties to detect when RootFolder.ServerRelativeUrl is not loaded yet.
Environment details (development & target environment)
Additional context
I put lots of Console.WriteLines in the code and this is what I found:
This method:
| private static List<Expression<Func<TModel, object>>> VerifyProperties(IDataModel<TModel> model, Expression<Func<TModel, object>>[] expressions, ref bool dirty) |
...fails to handle this expression properly:
pnpcore/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs
Lines 27 to 28 in cc8858f
| private static readonly Expression<Func<IList, object>>[] getPagesLibraryExpression = new Expression<Func<IList, object>>[] {p => p.Title, p => p.TemplateType, p => p.EnableFolderCreation, | |
| p => p.EnableMinorVersions, p => p.EnableModeration, p => p.EnableVersioning, p => p.ForceCheckout, p => p.RootFolder.QueryProperties(p => p.Properties, p => p.ServerRelativeUrl), p => p.ListItemEntityTypeFullName, p => p.Fields }; |
Specifically it fails to dive into the properties defined in p.RootFolder.QueryProperties here:
pnpcore/src/sdk/PnP.Core/Model/Base/BaseDataModel.cs
Lines 1299 to 1300 in 119c3ee
| var collection = model.GetPublicInstancePropertyValue(fieldToLoad); | |
| if (collection is IRequestableCollection) |
collection here is of type PnP.Core.Model.SharePoint.Folder (fieldToLoad == "RootFolder"), not IRequestableCollection. This immediately leaves the function leaving the dirty flag unchecked. This leads to errors in other code that now assumes that e.g. the RootFolder.ServerRelativeUrl property is loaded. Because it might not be. And in my case sometimes wasn't.
I have no clue how to fix this ^^