Skip to content

Commit

Permalink
Fixed DataSource deserialization. (microsoft#859)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haplois authored Jun 4, 2021
1 parent f6731ef commit 640372c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
23 changes: 23 additions & 0 deletions scripts/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,25 @@ function Print-Help {
Exit 0
}

function Install-WindowsSDK {
Push-Location
$temp = [System.IO.Path]::GetTempFileName();
Remove-Item $temp
New-Item $temp -Type Directory | Out-Null
Set-Location $temp

try {
Invoke-WebRequest -Method Get -Uri https://go.microsoft.com/fwlink/p/?LinkId=838916 -OutFile sdksetup.exe -UseBasicParsing
Start-Process -Wait sdksetup.exe -ArgumentList "/q", "/norestart", "/ceip off", "/features OptionId.WindowsSoftwareDevelopmentKit" -Wait -PassThru
}
finally {
Pop-Location

Remove-Item $temp -Force -Recurse | Out-Null
}

}

#
# Restores packages for the solutions.
#
Expand Down Expand Up @@ -285,6 +304,10 @@ if (ShouldRunStep @("UpdateTPVersion")) {
Sync-PackageVersions
}

if (ShouldRunStep @("Install-WindowsSDK")) {
Install-WindowsSDK
}

if (ShouldRunStep @("UpdateTPVersion", "Restore")) {
Perform-Restore
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ public static object[] Deserialize(string[] serializedData, params Assembly[] as
for (int i = 0; i < length; i++)
{
var typeIndex = i * 2;
var dataIndex = typeIndex + 1;
var typeName = serializedData[typeIndex];
var serializedValue = serializedData[typeIndex + 1];

if (serializedData[i] == null)
if (serializedValue == null || typeName == null)
{
data[i] = null;
continue;
}

var typeName = serializedData[typeIndex];
var serializer = GetSerializer(typeName, assemblies);

var serialzedDataBytes = Encoding.UTF8.GetBytes(serializedData[dataIndex]);
var serialzedDataBytes = Encoding.UTF8.GetBytes(serializedValue);
using (var memoryStream = new MemoryStream(serialzedDataBytes))
{
data[i] = serializer.ReadObject(memoryStream);
Expand Down

0 comments on commit 640372c

Please sign in to comment.