File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -246,10 +246,17 @@ private string CheckWinGetVersion()
246246
247247 for ( int i = 0 ; i < result . Output . Length ; i ++ )
248248 {
249+ #if NETCOREAPP3_1_OR_GREATER
250+ if ( result . Output [ i ] . StartsWith ( 'v' ) )
251+ {
252+ return result . Output [ i ] . Trim ( ) ;
253+ }
254+ #elif NETSTANDARD2_0
249255 if ( result . Output [ i ] . StartsWith ( "v" ) )
250256 {
251257 return result . Output [ i ] . Trim ( ) ;
252258 }
259+ #endif
253260 }
254261 }
255262 catch
@@ -281,7 +288,7 @@ private Version GetVersionObject()
281288 break ;
282289 }
283290 }
284- #elif NETSTANDARD2_0
291+ #elif NETSTANDARD2_0
285292 //Remove the first letter from the version string.
286293 if ( versionString . StartsWith ( "v" ) )
287294 {
@@ -300,7 +307,7 @@ private Version GetVersionObject()
300307 }
301308#endif
302309
303- if ( ! Version . TryParse ( versionString , out Version ? versionObject ) || versionObject == null )
310+ if ( ! Version . TryParse ( versionString , out Version ? versionObject ) )
304311 {
305312 versionObject = Version . Parse ( "0.0.0" ) ;
306313 }
Original file line number Diff line number Diff line change @@ -1042,18 +1042,32 @@ private List<WinGetSource> ExportStringToSources(string exportString)
10421042 StringBuilder jsonString = new ( ) ;
10431043 for ( int i = 0 ; i < jsonStrings . Length ; i ++ )
10441044 {
1045+ #if NETCOREAPP3_1_OR_GREATER
1046+ if ( ! jsonStrings [ i ] . StartsWith ( '{' ) )
1047+ {
1048+ jsonString . Append ( "{" ) ;
1049+ }
1050+ #elif NETSTANDARD2_0
10451051 if ( ! jsonStrings [ i ] . StartsWith ( "{" ) )
10461052 {
10471053 jsonString . Append ( "{" ) ;
10481054 }
1055+ #endif
10491056
10501057 jsonString . Append ( jsonStrings [ i ] ) ;
10511058
1059+ #if NETCOREAPP3_1_OR_GREATER
1060+ if ( ! jsonStrings [ i ] . EndsWith ( '}' ) )
1061+ {
1062+ jsonString . Append ( "}" ) ;
1063+ }
1064+ #elif NETSTANDARD2_0
10521065 if ( ! jsonStrings [ i ] . EndsWith ( "}" ) )
10531066 {
10541067 jsonString . Append ( "}" ) ;
10551068 }
1056-
1069+ #endif
1070+
10571071 WinGetSource ? source =
10581072 JsonHandler . StringToObject < WinGetSource > ( jsonString . ToString ( ) )
10591073 ?? throw new WinGetActionFailedException ( "Exporting sources failed. Could not parse json." ) ;
@@ -1087,14 +1101,14 @@ private async Task<List<WinGetSource>> ExportStringToSourcesAsync(string exportS
10871101 StringBuilder jsonString = new ( ) ;
10881102 for ( int i = 0 ; i < jsonStrings . Length ; i ++ )
10891103 {
1090- if ( ! jsonStrings [ i ] . StartsWith ( "{" ) )
1104+ if ( ! jsonStrings [ i ] . StartsWith ( '{' ) )
10911105 {
10921106 jsonString . Append ( "{" ) ;
10931107 }
10941108
10951109 jsonString . Append ( jsonStrings [ i ] ) ;
10961110
1097- if ( ! jsonStrings [ i ] . EndsWith ( "}" ) )
1111+ if ( ! jsonStrings [ i ] . EndsWith ( '}' ) )
10981112 {
10991113 jsonString . Append ( "}" ) ;
11001114 }
You can’t perform that action at this time.
0 commit comments