Skip to content

Commit

Permalink
fix: Remove span dependency for ShellTask
Browse files Browse the repository at this point in the history
Fixes errors such as :
```
System.IO.FileLoadException: Could not load file or assembly 'System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
```
  • Loading branch information
jeromelaban committed Nov 20, 2020
1 parent 716af55 commit ec63d37
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Uno.Wasm.Bootstrap/ShellTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -825,27 +825,30 @@ private void TryAdjustAOTProfile()

if (profilePath != null)
{
var span = File.ReadAllBytes(profilePath).AsSpan();
var fileContent = File.ReadAllBytes(profilePath);

var replacedMethods = new[] { "LoadIntoBufferAsync" };

foreach (var method in replacedMethods)
{
var searchSpan = Encoding.ASCII.GetBytes(method).AsSpan();
var searchContent = Encoding.ASCII.GetBytes(method);
var slice = new byte[searchContent.Length];

for (int i = 0; i < span.Length - searchSpan.Length; i++)
for (int i = 0; i < fileContent.Length - searchContent.Length; i++)
{
if (span[i] == searchSpan[0])
if (fileContent[i] == searchContent[0])
{
if (span.Slice(i, searchSpan.Length).SequenceEqual(searchSpan))
Buffer.BlockCopy(fileContent, i, slice, 0, searchContent.Length);

if (fileContent.SequenceEqual(searchContent))
{
span[i] = (byte)'_';
fileContent[i] = (byte)'_';
}
}
}
}

File.WriteAllBytes(profilePath, span.ToArray());
File.WriteAllBytes(profilePath, fileContent);
}
}

Expand Down

0 comments on commit ec63d37

Please sign in to comment.