@@ -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 } ";
@@ -884,19 +884,19 @@ public static bool TryConvertFromContainerRegistryJson(
884
884
metadata [ "NormalizedVersion" ] = parsedNormalizedVersion . ToNormalizedString ( ) ;
885
885
886
886
// 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 ) )
888
888
{
889
889
metadata [ "LicenseUrl" ] = ParseHttpUrl ( licenseUrlElement . ToString ( ) ) as Uri ;
890
890
}
891
891
892
892
// 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 ) )
894
894
{
895
895
metadata [ "ProjectUrl" ] = ParseHttpUrl ( projectUrlElement . ToString ( ) ) as Uri ;
896
896
}
897
897
898
898
// 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 ) )
900
900
{
901
901
metadata [ "IconUrl" ] = ParseHttpUrl ( iconUrlElement . ToString ( ) ) as Uri ;
902
902
}
@@ -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,39 @@ 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 . 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
+
990
1019
var additionalMetadataHashtable = new Dictionary < string , string >
991
1020
{
992
1021
{ "NormalizedVersion" , metadata [ "NormalizedVersion" ] . ToString ( ) }
0 commit comments