Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TestXmlReferenceResolver semantics for missing files #751

Merged
merged 1 commit into from
Mar 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
Expand All @@ -24,18 +25,28 @@ public override int GetHashCode()
return RuntimeHelpers.GetHashCode(this);
}

public override Stream? OpenRead(string resolvedPath)
public override Stream OpenRead(string resolvedPath)
{
if (resolvedPath is null)
{
throw new ArgumentNullException(nameof(resolvedPath));
}

if (!XmlReferences.TryGetValue(resolvedPath, out var content))
{
return null;
throw new IOException($"Unable to read XML file: {resolvedPath}");
}

return new MemoryStream(Encoding.UTF8.GetBytes(content));
}

public override string ResolveReference(string path, string baseFilePath)
public override string? ResolveReference(string path, string baseFilePath)
{
if (!XmlReferences.ContainsKey(path))
{
return null;
}

return path;
}
}
Expand Down