Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9c53f72

Browse files
committed
Add support for hexadecimal values (like 0xFF) ​​to msbuild property BaseAddress
This was a bug, because loading a project with <BaseAddress>0x06800000</BaseAddress>the property value was silently ignored
1 parent67829f1 commit9c53f72

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

‎vsintegration/src/unittests/Tests.ProjectSystem.Miscellaneous.fs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,15 @@ type Utilities() =
768768
()
769769

770770

771+
[<Test>]
772+
memberpublicthis.``Parse MSBuild property of type Int64``()=
773+
Assert.AreEqual(123L, ProjectNode.ParsePropertyValueToInt64("123"))
774+
Assert.AreEqual(255L, ProjectNode.ParsePropertyValueToInt64("0xFF"))
775+
Assert.AreEqual(null, ProjectNode.ParsePropertyValueToInt64(""))
776+
Assert.AreEqual(null, ProjectNode.ParsePropertyValueToInt64(null))
777+
Assert.Throws<Exception>(fun()-> ignore(ProjectNode.ParsePropertyValueToInt64("abc")))|> ignore
778+
Assert.Throws<Exception>(fun()-> ignore(ProjectNode.ParsePropertyValueToInt64("12333333333333333333333333")))|> ignore
779+
771780

772781
#if DEBUGGERVISUALIZER
773782
moduleinternalDebugViz=

‎vsintegration/src/vs/FsPkgs/FSharp.Project/Common.Source.CSharp/Project/ProjectNode.cs‎

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,6 +2560,24 @@ public virtual void SetOrCreateBuildEventProperty(string propertyName, string pr
25602560
}
25612561
}
25622562

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+
publicstaticlong?ParsePropertyValueToInt64(strings)
2569+
{
2570+
if(string.IsNullOrWhiteSpace(s))
2571+
returnnull;
2572+
2573+
varconverter=newSystem.ComponentModel.Int64Converter();
2574+
varresult=converter.ConvertFromInvariantString(s);
2575+
if(result==null)
2576+
returnnull;
2577+
2578+
return(long)result;
2579+
}
2580+
25632581
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization","CA1308:NormalizeStringsToUppercase")]
25642582
internalvirtualProjectOptionsGetProjectOptions(ConfigCanonicalNameconfigCanonicalName)
25652583
{
@@ -2638,28 +2656,16 @@ internal virtual ProjectOptions GetProjectOptions(ConfigCanonicalName configCano
26382656
options.AllowUnsafeCode=true;
26392657
}
26402658

2641-
if(GetProjectProperty("BaseAddress",false)!=null)
2659+
stringbaseAddressPropertyString=GetProjectProperty("BaseAddress",false);
2660+
try
26422661
{
2643-
try
2644-
{
2645-
options.BaseAddress=Int64.Parse(GetProjectProperty("BaseAddress",false),CultureInfo.InvariantCulture);
2646-
}
2647-
catch(ArgumentNullExceptione)
2648-
{
2649-
Trace.WriteLine("Exception : "+e.Message);
2650-
}
2651-
catch(ArgumentExceptione)
2652-
{
2653-
Trace.WriteLine("Exception : "+e.Message);
2654-
}
2655-
catch(FormatExceptione)
2656-
{
2657-
Trace.WriteLine("Exception : "+e.Message);
2658-
}
2659-
catch(OverflowExceptione)
2660-
{
2661-
Trace.WriteLine("Exception : "+e.Message);
2662-
}
2662+
varresult=ParsePropertyValueToInt64(baseAddressPropertyString);
2663+
if(result.HasValue)
2664+
options.BaseAddress=result.Value;
2665+
}
2666+
catch(Exceptione)
2667+
{
2668+
Trace.WriteLine(string.Format("Exception parsing property {0}='{1}': {2}","BaseAddress",baseAddressPropertyString,e.Message));
26632669
}
26642670

26652671
if(GetBoolAttr("CheckForOverflowUnderflow"))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp