@@ -852,9 +852,9 @@ public static bool TryConvertFromContainerRegistryJson(
852
852
pkgVersion = ParseHttpVersion ( versionValue , out string prereleaseLabel ) ;
853
853
metadata [ "Version" ] = pkgVersion ;
854
854
855
- if ( rootDom . TryGetProperty ( "PrivateData" , out JsonElement privateDataElement ) && privateDataElement . TryGetProperty ( "PSData" , out JsonElement psDataElement ) )
855
+ if ( rootDom . TryGetProperty ( "PrivateData" , out JsonElement versionPrivateDataElement ) && versionPrivateDataElement . TryGetProperty ( "PSData" , out JsonElement versionPSDataElement ) )
856
856
{
857
- if ( psDataElement . TryGetProperty ( "Prerelease" , out JsonElement pkgPrereleaseLabelElement ) && ! String . IsNullOrEmpty ( pkgPrereleaseLabelElement . ToString ( ) . Trim ( ) ) )
857
+ if ( versionPSDataElement . TryGetProperty ( "Prerelease" , out JsonElement pkgPrereleaseLabelElement ) && ! String . IsNullOrEmpty ( pkgPrereleaseLabelElement . ToString ( ) . Trim ( ) ) )
858
858
{
859
859
prereleaseLabel = pkgPrereleaseLabelElement . ToString ( ) . Trim ( ) ;
860
860
versionValue += $ "-{ prereleaseLabel } ";
@@ -938,14 +938,19 @@ public static bool TryConvertFromContainerRegistryJson(
938
938
}
939
939
940
940
// Author
941
- if ( rootDom . TryGetProperty ( "Authors" , out JsonElement authorsElement ) || rootDom . TryGetProperty ( "authors" , out authorsElement ) )
941
+ if ( rootDom . TryGetProperty ( "Authors" , out JsonElement authorsElement ) || rootDom . TryGetProperty ( "authors" , out authorsElement ) || rootDom . TryGetProperty ( "Author" , out authorsElement ) )
942
942
{
943
943
metadata [ "Authors" ] = authorsElement . ToString ( ) ;
944
+ }
944
945
945
- // CompanyName
946
- // CompanyName is not provided in v3 pkg metadata response, so we've just set it to the author,
947
- // which is often the company
948
- metadata [ "CompanyName" ] = authorsElement . ToString ( ) ;
946
+ if ( rootDom . TryGetProperty ( "CompanyName" , out JsonElement companyNameElement ) )
947
+ {
948
+ metadata [ "CompanyName" ] = companyNameElement . ToString ( ) ;
949
+ }
950
+ else
951
+ {
952
+ // if CompanyName property is not provided set it to the Author value which is often the same.
953
+ metadata [ "CompanyName" ] = metadata [ "Authors" ] ;
949
954
}
950
955
951
956
// Copyright
@@ -978,15 +983,62 @@ public static bool TryConvertFromContainerRegistryJson(
978
983
{
979
984
metadata [ "Dependencies" ] = ParseContainerRegistryDependencies ( moduleListDepsElement , out errorMsg ) . ToArray ( ) ;
980
985
}
981
- else if ( rootDom . TryGetProperty ( "PrivateData" , out JsonElement privateDataElement ) && privateDataElement . TryGetProperty ( "PSData" , out JsonElement psDataElement ) )
986
+ else if ( rootDom . TryGetProperty ( "PrivateData" , out JsonElement depsPrivateDataElement ) && depsPrivateDataElement . TryGetProperty ( "PSData" , out JsonElement depsPSDataElement ) )
982
987
{
983
- if ( psDataElement . TryGetProperty ( "ModuleList" , out JsonElement privateDataModuleListDepsElement ) )
988
+ if ( depsPSDataElement . TryGetProperty ( "ModuleList" , out JsonElement privateDataModuleListDepsElement ) )
984
989
{
985
990
metadata [ "Dependencies" ] = ParseContainerRegistryDependencies ( privateDataModuleListDepsElement , out errorMsg ) . ToArray ( ) ;
986
991
}
987
992
}
988
993
}
989
994
995
+ if ( rootDom . TryGetProperty ( "PrivateData" , out JsonElement privateDataElement ) && privateDataElement . ValueKind == JsonValueKind . Object && privateDataElement . TryGetProperty ( "PSData" , out JsonElement psDataElement ) )
996
+ {
997
+ // some properties that may be in PrivateData.PSData: LicenseUri, ProjectUri, IconUri, ReleaseNotes
998
+ if ( ! metadata . ContainsKey ( "LicenseUrl" ) && psDataElement . TryGetProperty ( "LicenseUri" , out JsonElement psDataLicenseUriElement ) )
999
+ {
1000
+ metadata [ "LicenseUrl" ] = ParseHttpUrl ( psDataLicenseUriElement . ToString ( ) ) as Uri ;
1001
+ }
1002
+
1003
+ if ( ! metadata . ContainsKey ( "ProjectUrl" ) && psDataElement . TryGetProperty ( "ProjectUri" , out JsonElement psDataProjectUriElement ) )
1004
+ {
1005
+ metadata [ "ProjectUrl" ] = ParseHttpUrl ( psDataProjectUriElement . ToString ( ) ) as Uri ;
1006
+ }
1007
+
1008
+ if ( ! metadata . ContainsKey ( "IconUrl" ) && psDataElement . TryGetProperty ( "IconUri" , out JsonElement psDataIconUriElement ) )
1009
+ {
1010
+ metadata [ "IconUrl" ] = ParseHttpUrl ( psDataIconUriElement . ToString ( ) ) as Uri ;
1011
+ }
1012
+
1013
+ if ( ! metadata . ContainsKey ( "ReleaseNotes" ) && psDataElement . TryGetProperty ( "ReleaseNotes" , out JsonElement psDataReleaseNotesElement ) )
1014
+ {
1015
+ metadata [ "ReleaseNotes" ] = psDataReleaseNotesElement . ToString ( ) ;
1016
+ }
1017
+
1018
+ if ( ! metadata . ContainsKey ( "Tags" ) && psDataElement . TryGetProperty ( "Tags" , out JsonElement psDataTagsElement ) )
1019
+ {
1020
+ string [ ] pkgTags = Utils . EmptyStrArray ;
1021
+ if ( psDataTagsElement . ValueKind == JsonValueKind . Array )
1022
+ {
1023
+ var arrayLength = psDataTagsElement . GetArrayLength ( ) ;
1024
+ List < string > tags = new List < string > ( arrayLength ) ;
1025
+ foreach ( var tag in psDataTagsElement . EnumerateArray ( ) )
1026
+ {
1027
+ tags . Add ( tag . ToString ( ) ) ;
1028
+ }
1029
+
1030
+ pkgTags = tags . ToArray ( ) ;
1031
+ }
1032
+ else if ( psDataTagsElement . ValueKind == JsonValueKind . String )
1033
+ {
1034
+ string tagStr = psDataTagsElement . ToString ( ) ;
1035
+ pkgTags = tagStr . Split ( Utils . WhitespaceSeparator , StringSplitOptions . RemoveEmptyEntries ) ;
1036
+ }
1037
+
1038
+ metadata [ "Tags" ] = pkgTags ;
1039
+ }
1040
+ }
1041
+
990
1042
var additionalMetadataHashtable = new Dictionary < string , string >
991
1043
{
992
1044
{ "NormalizedVersion" , metadata [ "NormalizedVersion" ] . ToString ( ) }
0 commit comments