@@ -852,9 +852,9 @@ public static bool TryConvertFromContainerRegistryJson(
852852 pkgVersion = ParseHttpVersion ( versionValue , out string prereleaseLabel ) ;
853853 metadata [ "Version" ] = pkgVersion ;
854854
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 ) )
856856 {
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 ( ) ) )
858858 {
859859 prereleaseLabel = pkgPrereleaseLabelElement . ToString ( ) . Trim ( ) ;
860860 versionValue += $ "-{ prereleaseLabel } ";
@@ -884,19 +884,19 @@ public static bool TryConvertFromContainerRegistryJson(
884884 metadata [ "NormalizedVersion" ] = parsedNormalizedVersion . ToNormalizedString ( ) ;
885885
886886 // License Url
887- if ( rootDom . TryGetProperty ( "LicenseUrl" , out JsonElement licenseUrlElement ) || rootDom . TryGetProperty ( "licenseUrl" , out licenseUrlElement ) )
887+ if ( rootDom . TryGetProperty ( "LicenseUrl" , out JsonElement licenseUrlElement ) || rootDom . TryGetProperty ( "licenseUrl" , out licenseUrlElement ) || rootDom . TryGetProperty ( "LicenseUri" , out licenseUrlElement ) )
888888 {
889889 metadata [ "LicenseUrl" ] = ParseHttpUrl ( licenseUrlElement . ToString ( ) ) as Uri ;
890890 }
891891
892892 // Project Url
893- if ( rootDom . TryGetProperty ( "ProjectUrl" , out JsonElement projectUrlElement ) || rootDom . TryGetProperty ( "projectUrl" , out projectUrlElement ) )
893+ if ( rootDom . TryGetProperty ( "ProjectUrl" , out JsonElement projectUrlElement ) || rootDom . TryGetProperty ( "projectUrl" , out projectUrlElement ) || rootDom . TryGetProperty ( "ProjectUri" , out projectUrlElement ) )
894894 {
895895 metadata [ "ProjectUrl" ] = ParseHttpUrl ( projectUrlElement . ToString ( ) ) as Uri ;
896896 }
897897
898898 // Icon Url
899- if ( rootDom . TryGetProperty ( "IconUrl" , out JsonElement iconUrlElement ) || rootDom . TryGetProperty ( "iconUrl" , out iconUrlElement ) )
899+ if ( rootDom . TryGetProperty ( "IconUrl" , out JsonElement iconUrlElement ) || rootDom . TryGetProperty ( "iconUrl" , out iconUrlElement ) || rootDom . TryGetProperty ( "IconUri" , out iconUrlElement ) )
900900 {
901901 metadata [ "IconUrl" ] = ParseHttpUrl ( iconUrlElement . ToString ( ) ) as Uri ;
902902 }
@@ -938,14 +938,19 @@ public static bool TryConvertFromContainerRegistryJson(
938938 }
939939
940940 // 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 ) )
942942 {
943943 metadata [ "Authors" ] = authorsElement . ToString ( ) ;
944+ }
944945
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" ] ;
949954 }
950955
951956 // Copyright
@@ -978,15 +983,39 @@ public static bool TryConvertFromContainerRegistryJson(
978983 {
979984 metadata [ "Dependencies" ] = ParseContainerRegistryDependencies ( moduleListDepsElement , out errorMsg ) . ToArray ( ) ;
980985 }
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 ) )
982987 {
983- if ( psDataElement . TryGetProperty ( "ModuleList" , out JsonElement privateDataModuleListDepsElement ) )
988+ if ( depsPSDataElement . TryGetProperty ( "ModuleList" , out JsonElement privateDataModuleListDepsElement ) )
984989 {
985990 metadata [ "Dependencies" ] = ParseContainerRegistryDependencies ( privateDataModuleListDepsElement , out errorMsg ) . ToArray ( ) ;
986991 }
987992 }
988993 }
989994
995+ if ( rootDom . TryGetProperty ( "PrivateData" , out JsonElement privateDataElement ) && 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" ) || 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" ) || 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" ) || 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+
9901019 var additionalMetadataHashtable = new Dictionary < string , string >
9911020 {
9921021 { "NormalizedVersion" , metadata [ "NormalizedVersion" ] . ToString ( ) }
0 commit comments