Repository navigation
[Data model] Package factory - #6326
Conversation
|
This PR contains changes to XAML files. Verify that you've completed the following tasks:
|
e8f88ee to
ef2009a
Compare
| public string? Authors { get; } | ||
|
|
||
| public IReadOnlyList<string>? OwnersList { get; } | ||
| public string? Owners { get; } |
There was a problem hiding this comment.
Why are we going back to a string of owners after deciding to have a list of owners?
There was a problem hiding this comment.
PackageSearchMetadataContextInfo has OwnersList and Owners as properties, but PackageViewModel only uses Owners and I cannot find where we actually use OwnersList, not sure why we have both but given that Owners is the only one used in the ViewModel I think we should use that one instead of OwnersList which is not used
There was a problem hiding this comment.
Why are we going back to a string of owners after deciding to have a list of owners?
@jebriede When was this decision made?
not sure why we have both
@martinrrm did you look at the history of the code you referenced when creating this model? There should be a PR when I made changes for the Owner work and it was intentional to have both. There should be PR Description and review feedback about it.
There was a problem hiding this comment.
@donnie-msft I'm glad to get your perspective about this! We want our model to represent structured data and have the comma-delimited list for display purposes.
@martinrrm let's find that PR and make sure we're not missing anything to have one representation in the new model.
There was a problem hiding this comment.
@donnie-msft There's 10 closed PRs that mention owners! 🙂 Would you mind pointing us at the PR and the comment that helps understand why the PackageSearchMetadataContextInfo has both a comma-delimited list and a list of owners? That would be very helpful!
There was a problem hiding this comment.
@donnie-msft do you mean this pr? #5751
It sounds like we needed both when converting from JSON because the v2 api returns owners as a string, which caused an exception. These changes aren't impacting how we parse the data from the API.
The model in the PM UI shouldn't care about implementation details from different APIs, I think we should pick one and stick with it. My preference is the ReadonlyList of Owners, it leaves formatting the owners for the presentation layer up to the ViewModel.
There was a problem hiding this comment.
I highly recommend using git blame rather than searching keywords in git when understanding existing code.
@jgonz120 yes, you found where Protocol provides both Owners & OwnersList! Both are part of the NuGet API and can be used as needed by the PM UI. The ViewModel today uses Owners and OwnerList, here's one example:
My preference is the ReadonlyList of Owners, it leaves formatting the owners for the presentation layer up to the ViewModel.
Yes, and the OwnersList is what's used today when rendering the owner hyperlinks. In places like the ToolTip, the string is used.
Rebuilding this owner string from the owners list in the UI is something you could do but just note that the string is already given to you directly by the NuGet API.
There was a problem hiding this comment.
Oh I see from the docs, https://learn.microsoft.com/en-us/nuget/api/search-query-service-resource#search-result, the owner can be returned from the API as a string representing a single owner. I wonder if we actually need to preemptively convert the list of owners to a string.
f4931d1 to
2961e97
Compare
| } | ||
|
|
||
| var listItem = new PackageItemViewModel(_searchService, _packageVulnerabilityService) | ||
| PackageModel packageModel = _packageModelFactory.Create(metadataContextInfo, _itemFilter); |
There was a problem hiding this comment.
Will this still create an installed package if we're on the browse tab and the package has been installed?
There was a problem hiding this comment.
Can you help me understand this scenario with our package models?
4742eab to
a892893
Compare

Bug
Fixes:
Description
Adds a factory class to create the corresponding PackageModel depending on the metadata provided.
This PR also adds the PackageModel to the PckageItemViewModel
PR Checklist