Repository navigation
Expand file tree
/
Copy pathScriptSourceResolver.cs
More file actions
52 lines (40 loc) · 1.88 KB
/
Copy pathScriptSourceResolver.cs
File metadata and controls
52 lines (40 loc) · 1.88 KB
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
50
51
52
// 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.Collections.Generic;
using System.Collections.Immutable;
namespace Microsoft.CodeAnalysis.Scripting
{
using static ParameterValidationHelpers;
public sealed class ScriptSourceResolver : SourceFileResolver, IEquatable<ScriptSourceResolver>
{
public static new ScriptSourceResolver Default { get; } = new ScriptSourceResolver(ImmutableArray<string>.Empty, null);
private ScriptSourceResolver(ImmutableArray<string> sourcePaths, string baseDirectory)
: base(sourcePaths, baseDirectory)
{
}
public ScriptSourceResolver WithSearchPaths(params string[] searchPaths)
=> WithSearchPaths(searchPaths.AsImmutableOrEmpty());
public ScriptSourceResolver WithSearchPaths(IEnumerable<string> searchPaths)
=> WithSearchPaths(searchPaths.AsImmutableOrEmpty());
public ScriptSourceResolver WithSearchPaths(ImmutableArray<string> searchPaths)
{
if (SearchPaths == searchPaths)
{
return this;
}
return new ScriptSourceResolver(ToImmutableArrayChecked(searchPaths, nameof(searchPaths)), BaseDirectory);
}
public ScriptSourceResolver WithBaseDirectory(string baseDirectory)
{
if (BaseDirectory == baseDirectory)
{
return this;
}
// absolute path check is done in the base class
return new ScriptSourceResolver(SearchPaths, baseDirectory);
}
public bool Equals(ScriptSourceResolver other) => base.Equals(other);
public override int GetHashCode() => base.GetHashCode();
public override bool Equals(object obj) => base.Equals(obj);
}
}