Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Munn <gregm@microsoft.com>2019-07-30 18:13:06 +0300
committerGitHub <noreply@github.com>2019-07-30 18:13:06 +0300
commit370d5965b4b3b69d3010f916c7790afc15841a61 (patch)
treee4afd86b12a0e92c942caafa5d4ddb86a8c31670 /main/src/addins
parentd6ba14dc61930fb243ace098e226658670c73208 (diff)
parent67f4c0243307ed435c3581e74dd2a7e29f8e288c (diff)
Merge pull request #8268 from mono/jstedfast-dotnetcore-src-hash
[Debugger] Fixed .NET Core debugger to allow use of SHA256 and MD5 ha…
Diffstat (limited to 'main/src/addins')
-rw-r--r--main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/CustomSoftDebuggerEngine.cs2
-rw-r--r--main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VsCodeStackFrame.cs57
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj5
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/VsCodeStackFrameTests.cs49
4 files changed, 100 insertions, 13 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/CustomSoftDebuggerEngine.cs b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/CustomSoftDebuggerEngine.cs
index 2e5e08f885..0ed6f75f22 100644
--- a/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/CustomSoftDebuggerEngine.cs
+++ b/main/src/addins/MonoDevelop.Debugger.Soft/MonoDevelop.Debugger.Soft/CustomSoftDebuggerEngine.cs
@@ -340,7 +340,7 @@ namespace MonoDevelop.Debugger.Soft
TimeBetweenConnectionAttempts = 800,
MaxConnectionAttempts = -1,
};
- };
+ }
var dsi = new SoftDebuggerStartInfo (startArgs) {
Command = StringParserService.Parse (command),
diff --git a/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VsCodeStackFrame.cs b/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VsCodeStackFrame.cs
index 09930da9ee..a72aeb7634 100644
--- a/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VsCodeStackFrame.cs
+++ b/main/src/addins/MonoDevelop.Debugger.VSCodeDebugProtocol/MonoDevelop.Debugger.VsCodeDebugProtocol/VsCodeStackFrame.cs
@@ -10,7 +10,7 @@ using VsFormat = Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Messages.Stac
namespace MonoDevelop.Debugger.VsCodeDebugProtocol
{
- class VsCodeStackFrame : Mono.Debugging.Client.StackFrame
+ public class VsCodeStackFrame : Mono.Debugging.Client.StackFrame
{
public static VsFormat GetStackFrameFormat (EvaluationOptions evalOptions)
{
@@ -58,25 +58,58 @@ namespace MonoDevelop.Debugger.VsCodeDebugProtocol
this.frameId = frame.Id;
}
- static byte [] HexToByteArray (string hex)
+ static byte ToXDigit (char c)
+ {
+ if (c >= 'A' && c <= 'F')
+ return (byte) ((c - 'A') + 10);
+
+ if (c >= 'a' && c <= 'f')
+ return (byte) ((c - 'a') + 10);
+
+ if (c >= '0' && c <= '9')
+ return (byte) (c - '0');
+
+ throw new ArgumentException ();
+ }
+
+ public static byte[] HexToByteArray (string hex)
{
if (hex.Length % 2 == 1)
- throw new ArgumentException ();
- byte [] bytes = new byte [hex.Length / 2];
- for (int i = 0; i < bytes.Length; i++) {
- bytes [i] = Convert.ToByte (hex.Substring (i * 2, 2), 16);
+ return null;
+
+ try {
+ var bytes = new byte[hex.Length / 2];
+ for (int i = 0, j = 0; i < bytes.Length; i++, j += 2) {
+ var x1 = ToXDigit (hex[j]);
+ var x2 = ToXDigit (hex[j + 1]);
+
+ bytes[i] = (byte) ((x1 << 4) | x2);
+ }
+
+ return bytes;
+ } catch {
+ return null;
}
- return bytes;
}
- static byte [] GetHashBytes (Source source)
+ static byte[] GetHashBytes (Source source)
{
if (source == null)
return null;
- var checkSum = source.Checksums.FirstOrDefault (c => c.Algorithm == ChecksumAlgorithm.SHA1);
- if (checkSum == null)
- return null;
- return HexToByteArray (checkSum.ChecksumValue);
+
+ foreach (var checksum in source.Checksums) {
+ switch (checksum.Algorithm) {
+ case ChecksumAlgorithm.SHA256:
+ case ChecksumAlgorithm.SHA1:
+ case ChecksumAlgorithm.MD5:
+ var hash = HexToByteArray (checksum.ChecksumValue);
+ if (hash != null)
+ return hash;
+ break;
+ }
+ }
+
+ return null;
}
public override string FullStackframeText {
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj
index 66a368f365..75a26167f2 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/MonoDevelop.Debugger.Tests.csproj
@@ -21,6 +21,7 @@
<Compile Include="..\..\..\..\external\debugger-libs\UnitTests\Mono.Debugging.Tests\Shared\Win32\*.cs" />
<Compile Include="DebugTests.MonoDevelop.cs" />
<Compile Include="TextFile.cs" />
+ <Compile Include="VsCodeStackFrameTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MonoDevelop.Debugger.csproj">
@@ -63,6 +64,10 @@
<Name>Mono.Debugging.Soft</Name>
<Private>False</Private>
</ProjectReference>
+ <ProjectReference Include="..\..\MonoDevelop.Debugger.VSCodeDebugProtocol\MonoDevelop.Debugger.VsCodeDebugProtocol\MonoDevelop.Debugger.VsCodeDebugProtocol.csproj">
+ <Project>{10F5BBD5-8A1D-4563-BCE4-DE681DFD82FD}</Project>
+ <Name>MonoDevelop.Debugger.VsCodeDebugProtocol</Name>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/VsCodeStackFrameTests.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/VsCodeStackFrameTests.cs
new file mode 100644
index 0000000000..3576b8d19f
--- /dev/null
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Tests/VsCodeStackFrameTests.cs
@@ -0,0 +1,49 @@
+//
+// VsCodeStackFrameTests.cs
+//
+// Author:
+// Jeffrey Stedfast <jestedfa@microsoft.com>
+//
+// Copyright (c) 2019 Microsoft Corp.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using NUnit.Framework;
+
+using MonoDevelop.Debugger.VsCodeDebugProtocol;
+
+namespace MonoDevelop.Debugger.Tests
+{
+ [TestFixture]
+ public class VsCodeStackFrameTests
+ {
+ [Test]
+ public void TestHexDecode ()
+ {
+ var result = VsCodeStackFrame.HexToByteArray ("fFaAbB0012a1");
+
+ Assert.AreEqual ((byte) 0xff, result[0], "result[0]");
+ Assert.AreEqual ((byte) 0xaa, result[1], "result[1]");
+ Assert.AreEqual ((byte) 0xbb, result[2], "result[2]");
+ Assert.AreEqual ((byte) 0x00, result[3], "result[3]");
+ Assert.AreEqual ((byte) 0x12, result[4], "result[4]");
+ Assert.AreEqual ((byte) 0xa1, result[5], "result[5]");
+ }
+ }
+}