-
Notifications
You must be signed in to change notification settings - Fork 4k
/
XmlReferenceResolver.cs
49 lines (41 loc) · 2.16 KB
/
XmlReferenceResolver.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
namespace Microsoft.CodeAnalysis
{
/// <summary>
/// Resolves references to XML documents specified in source code.
/// </summary>
public abstract class XmlReferenceResolver
{
protected XmlReferenceResolver()
{
}
public abstract override bool Equals(object other);
public abstract override int GetHashCode();
/// <summary>
/// Resolves specified XML reference with respect to base file path.
/// </summary>
/// <param name="path">The reference path to resolve. May be absolute or relative path.</param>
/// <param name="baseFilePath">Path of the source file that contains the <paramref name="path"/> (may also be relative), or null if not available.</param>
/// <returns>Path to the XML artifact, or null if the file can't be resolved.</returns>
public abstract string ResolveReference(string path, string baseFilePath);
/// <summary>
/// Opens a <see cref="Stream"/> that allows reading the content of the specified file.
/// </summary>
/// <param name="resolvedPath">Path returned by <see cref="ResolveReference(string, string)"/>.</param>
/// <exception cref="ArgumentNullException"><paramref name="resolvedPath"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="resolvedPath"/> is not a valid absolute path.</exception>
/// <exception cref="IOException">Error reading file <paramref name="resolvedPath"/>. See <see cref="Exception.InnerException"/> for details.</exception>
public abstract Stream OpenRead(string resolvedPath);
internal Stream OpenReadChecked(string fullPath)
{
var stream = OpenRead(fullPath);
if (stream == null || !stream.CanRead)
{
throw new InvalidOperationException(CodeAnalysisResources.ReferenceResolverShouldReturnReadableNonNullStream);
}
return stream;
}
}
}