Skip to content

Commit

Permalink
Fix TestXmlReferenceResolver semantics for missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Mar 8, 2021
1 parent 425dcad commit 76b7c9c
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,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

0 comments on commit 76b7c9c

Please sign in to comment.