-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
AdditionalMetadataReferences.cs
36 lines (31 loc) · 1.59 KB
/
AdditionalMetadataReferences.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
using System.Collections.Immutable;
using System.IO;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.ML.Runtime;
namespace Microsoft.ML.CodeAnalyzer.Tests.Helpers
{
internal static class AdditionalMetadataReferences
{
#if NETCOREAPP
internal static readonly ReferenceAssemblies DefaultReferenceAssemblies = ReferenceAssemblies.Default
.AddPackages(ImmutableArray.Create(new PackageIdentity("System.Memory", "4.5.1")));
#else
internal static readonly ReferenceAssemblies DefaultReferenceAssemblies = ReferenceAssemblies.NetFramework.Net472.Default
.AddPackages(ImmutableArray.Create(new PackageIdentity("System.Memory", "4.5.1")));
#endif
internal static readonly MetadataReference MSDataDataViewReference = RefFromType<IDataView>();
internal static readonly MetadataReference MLNetCoreReference = RefFromType<IHostEnvironment>();
internal static readonly MetadataReference MLNetDataReference = RefFromType<MLContext>();
internal static MetadataReference RefFromType<TType>()
{
var location = typeof(TType).Assembly.Location;
var documentationProvider = XmlDocumentationProvider.CreateFromFile(Path.ChangeExtension(location, ".pdb"));
return MetadataReference.CreateFromFile(location, documentation: documentationProvider);
}
}
}