parent
2d49154d53
commit
f5065c9425
10 changed files with 76 additions and 40 deletions
|
@ -58,7 +58,7 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
}
|
||||
|
||||
private static bool EnumerableEquals(IEnumerable<string> left, IEnumerable<string> right)
|
||||
=> Enumerable.SequenceEqual(left ?? Array.Empty<string>(), right ?? Array.Empty<string>());
|
||||
=> Enumerable.SequenceEqual(left ?? EmptyArray<string>.Value, right ?? EmptyArray<string>.Value);
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
{
|
||||
if (@new != null)
|
||||
{
|
||||
old = old ?? Array.Empty<string>();
|
||||
old = old ?? EmptyArray<string>.Value;
|
||||
return old.Concat(@new).Distinct().ToArray();
|
||||
}
|
||||
return old;
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
var analyzers = GetAnalyzerReferences(package);
|
||||
|
||||
return new LibraryExport(package, compileAssemblies,
|
||||
sourceReferences, runtimeAssemblies, Array.Empty<LibraryAsset>(), nativeLibraries, analyzers);
|
||||
sourceReferences, runtimeAssemblies, EmptyArray<LibraryAsset>.Value, nativeLibraries, analyzers);
|
||||
}
|
||||
|
||||
private LibraryExport ExportProject(ProjectDescription project)
|
||||
|
@ -175,8 +175,8 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
sourceReferences: Enumerable.Empty<string>(),
|
||||
nativeLibraries: Enumerable.Empty<LibraryAsset>(),
|
||||
runtimeAssets: Enumerable.Empty<LibraryAsset>(),
|
||||
runtimeAssemblies: Array.Empty<LibraryAsset>(),
|
||||
analyzers: Array.Empty<AnalyzerReference>());
|
||||
runtimeAssemblies: EmptyArray<LibraryAsset>.Value,
|
||||
analyzers: EmptyArray<AnalyzerReference>.Value);
|
||||
}
|
||||
|
||||
var compileAssemblies = new List<LibraryAsset>();
|
||||
|
@ -226,7 +226,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
// just the same as compileAssemblies and nativeLibraries are empty
|
||||
// Also no support for analyzer projects
|
||||
return new LibraryExport(project, compileAssemblies, sourceReferences,
|
||||
compileAssemblies, runtimeAssets, Array.Empty<LibraryAsset>(), Array.Empty<AnalyzerReference>());
|
||||
compileAssemblies, runtimeAssets, EmptyArray<LibraryAsset>.Value, EmptyArray<AnalyzerReference>.Value);
|
||||
}
|
||||
|
||||
private static string ResolvePath(Project project, string configuration, string path)
|
||||
|
@ -250,13 +250,13 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
return new LibraryExport(
|
||||
library,
|
||||
string.IsNullOrEmpty(library.Path) ?
|
||||
Array.Empty<LibraryAsset>() :
|
||||
EmptyArray<LibraryAsset>.Value :
|
||||
new[] { new LibraryAsset(library.Identity.Name, library.Path, library.Path) },
|
||||
Array.Empty<string>(),
|
||||
Array.Empty<LibraryAsset>(),
|
||||
Array.Empty<LibraryAsset>(),
|
||||
Array.Empty<LibraryAsset>(),
|
||||
Array.Empty<AnalyzerReference>());
|
||||
EmptyArray<string>.Value,
|
||||
EmptyArray<LibraryAsset>.Value,
|
||||
EmptyArray<LibraryAsset>.Value,
|
||||
EmptyArray<LibraryAsset>.Value,
|
||||
EmptyArray<AnalyzerReference>.Value);
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetSharedSources(PackageDescription package)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel
|
||||
{
|
||||
|
@ -11,13 +11,19 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
{
|
||||
get
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return Windows; }
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { return Linux; }
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { return OSX; }
|
||||
|
||||
switch (PlatformServices.Default.Runtime.OperatingSystemPlatform)
|
||||
{
|
||||
case Platform.Windows:
|
||||
return Windows;
|
||||
case Platform.Darwin:
|
||||
return OSX;
|
||||
case Platform.Linux:
|
||||
return Linux;
|
||||
default:
|
||||
throw new InvalidOperationException("Unknown Platform");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static PlatformFileNameSuffixes DotNet { get; } = new PlatformFileNameSuffixes
|
||||
{
|
||||
|
|
14
src/Microsoft.DotNet.ProjectModel/Internal/EmptyArray.cs
Normal file
14
src/Microsoft.DotNet.ProjectModel/Internal/EmptyArray.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel
|
||||
{
|
||||
internal static class EmptyArray<T>
|
||||
{
|
||||
#if NET451
|
||||
public static readonly T[] Value = new T[0];
|
||||
#else
|
||||
public static readonly T[] Value = System.Array.Empty<T>();
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -144,9 +144,9 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
project.CompilerName = rawProject.ValueAsString("compilerName");
|
||||
project.TestRunner = rawProject.ValueAsString("testRunner");
|
||||
|
||||
project.Authors = rawProject.ValueAsStringArray("authors") ?? Array.Empty<string>();
|
||||
project.Owners = rawProject.ValueAsStringArray("owners") ?? Array.Empty<string>();
|
||||
project.Tags = rawProject.ValueAsStringArray("tags") ?? Array.Empty<string>();
|
||||
project.Authors = rawProject.ValueAsStringArray("authors") ?? EmptyArray<string>.Value;
|
||||
project.Owners = rawProject.ValueAsStringArray("owners") ?? EmptyArray<string>.Value;
|
||||
project.Tags = rawProject.ValueAsStringArray("tags") ?? EmptyArray<string>.Value;
|
||||
|
||||
project.Language = rawProject.ValueAsString("language");
|
||||
project.ReleaseNotes = rawProject.ValueAsString("releaseNotes");
|
||||
|
|
|
@ -5,10 +5,10 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.DotNet.ProjectModel.Utilities;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Resolution
|
||||
|
@ -60,7 +60,7 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
|
|||
return referenceAssembliesPath;
|
||||
}
|
||||
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if (PlatformServices.Default.Runtime.OperatingSystemPlatform != Platform.Windows)
|
||||
{
|
||||
// There is no reference assemblies path outside of windows
|
||||
// The environment variable can be used to specify one
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel.Utilities
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ namespace Microsoft.DotNet.ProjectModel.Utilities
|
|||
}
|
||||
|
||||
StringComparison compare;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if (PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows)
|
||||
{
|
||||
compare = StringComparison.OrdinalIgnoreCase;
|
||||
// check if paths are on the same volume
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
#if !NET451
|
||||
using System.Runtime.Loader;
|
||||
#endif
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using NuGet.Versioning;
|
||||
|
||||
|
@ -16,7 +19,11 @@ namespace Microsoft.DotNet.ProjectModel.Utilities
|
|||
|
||||
internal static NuGetVersion GetAssemblyVersion(string path)
|
||||
{
|
||||
#if NET451
|
||||
return new NuGetVersion(AssemblyName.GetAssemblyName(path).Version);
|
||||
#else
|
||||
return new NuGetVersion(AssemblyLoadContext.GetAssemblyName(path).Version);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string RenderVersion(VersionRange range)
|
||||
|
|
|
@ -5,15 +5,9 @@
|
|||
},
|
||||
"description": "Types to model a .NET Project",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Reflection.Metadata": "1.2.0-rc2-23811",
|
||||
"System.Runtime.Loader": "4.0.0-rc2-23811",
|
||||
"System.Dynamic.Runtime": "4.0.11-rc2-23811",
|
||||
"System.Security.Cryptography.Algorithms": "4.0.0-rc2-23811",
|
||||
"Microsoft.CSharp": "4.0.1-rc2-23811",
|
||||
"System.Xml.XDocument": "4.0.11-rc2-23811",
|
||||
"NuGet.Packaging": "3.4.0-beta-583",
|
||||
|
||||
"NuGet.Packaging": "3.4.0-beta-583",
|
||||
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-15996",
|
||||
"Microsoft.Extensions.JsonParser.Sources": {
|
||||
"type": "build",
|
||||
|
@ -28,10 +22,22 @@
|
|||
"version": "1.0.0-*"
|
||||
}
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"net451": {
|
||||
"frameworkAssemblies": {
|
||||
"System.IO": ""
|
||||
}
|
||||
},
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8"
|
||||
"imports": "portable-net45+win8",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Dynamic.Runtime": "4.0.11-rc2-23811",
|
||||
"System.Runtime.Loader": "4.0.0-rc2-23811",
|
||||
"System.Security.Cryptography.Algorithms": "4.0.0-rc2-23811",
|
||||
"Microsoft.CSharp": "4.0.1-rc2-23811",
|
||||
"System.Xml.XDocument": "4.0.11-rc2-23811"
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
@ -12,14 +12,17 @@
|
|||
"dependencies": {
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-rc2-16040",
|
||||
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-rc2-16040"
|
||||
},
|
||||
"frameworks": {
|
||||
"net451": { },
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8",
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||
"System.Resources.ResourceManager": "4.0.1-rc2-23811",
|
||||
"System.Runtime.Serialization.Primitives": "4.1.0-rc2-23811"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": {
|
||||
"imports": "portable-net45+win8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in a new issue