@@ -2560,6 +2560,24 @@ public virtual void SetOrCreateBuildEventProperty(string propertyName, string pr
2560
2560
}
2561
2561
}
2562
2562
2563
+ /// <remarks>Support hex format (like 0xFF)</remarks>
2564
+ /// <exception cref="System.Exception">
2565
+ /// Raise if invalid format
2566
+ /// The inner exception contains the real exception, of type FormatException, StackOverflowException
2567
+ /// </exception>
2568
+ public static long ? ParsePropertyValueToInt64 ( string s )
2569
+ {
2570
+ if ( string . IsNullOrWhiteSpace ( s ) )
2571
+ return null ;
2572
+
2573
+ var converter = new System . ComponentModel . Int64Converter ( ) ;
2574
+ var result = converter . ConvertFromInvariantString ( s ) ;
2575
+ if ( result == null )
2576
+ return null ;
2577
+
2578
+ return ( long ) result ;
2579
+ }
2580
+
2563
2581
[ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Microsoft.Globalization" , "CA1308:NormalizeStringsToUppercase" ) ]
2564
2582
internal virtual ProjectOptions GetProjectOptions ( ConfigCanonicalName configCanonicalName )
2565
2583
{
@@ -2638,28 +2656,16 @@ internal virtual ProjectOptions GetProjectOptions(ConfigCanonicalName configCano
2638
2656
options . AllowUnsafeCode = true ;
2639
2657
}
2640
2658
2641
- if ( GetProjectProperty ( "BaseAddress" , false ) != null )
2659
+ string baseAddressPropertyString = GetProjectProperty ( "BaseAddress" , false ) ;
2660
+ try
2642
2661
{
2643
- try
2644
- {
2645
- options . BaseAddress = Int64 . Parse ( GetProjectProperty ( "BaseAddress" , false ) , CultureInfo . InvariantCulture ) ;
2646
- }
2647
- catch ( ArgumentNullException e )
2648
- {
2649
- Trace . WriteLine ( "Exception : " + e . Message ) ;
2650
- }
2651
- catch ( ArgumentException e )
2652
- {
2653
- Trace . WriteLine ( "Exception : " + e . Message ) ;
2654
- }
2655
- catch ( FormatException e )
2656
- {
2657
- Trace . WriteLine ( "Exception : " + e . Message ) ;
2658
- }
2659
- catch ( OverflowException e )
2660
- {
2661
- Trace . WriteLine ( "Exception : " + e . Message ) ;
2662
- }
2662
+ var result = ParsePropertyValueToInt64 ( baseAddressPropertyString ) ;
2663
+ if ( result . HasValue )
2664
+ options . BaseAddress = result . Value ;
2665
+ }
2666
+ catch ( Exception e )
2667
+ {
2668
+ Trace . WriteLine ( string . Format ( "Exception parsing property {0}='{1}': {2}" , "BaseAddress" , baseAddressPropertyString , e . Message ) ) ;
2663
2669
}
2664
2670
2665
2671
if ( GetBoolAttr ( "CheckForOverflowUnderflow" ) )
0 commit comments