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