Fix projectmodel-server regression

1. Address the null reference exception when a project dependency is
broken.
2. Address the duplicate key issues after the logic of redirecting
System pacage to reference assembly was added

Update projectmodel-server and tests

1. Fix test timeout caused by undisconnected socket;
2. Update project model server
This commit is contained in:
Troy Dai 2016-01-29 01:49:56 -08:00
parent c4b3925e46
commit b9f2d8fe3d
12 changed files with 81 additions and 48 deletions

View file

@ -34,7 +34,8 @@ namespace Microsoft.DotNet.ProjectModel.Server
var allExports = context.CreateExporter(configuration)
.GetAllExports()
.ToDictionary(export => export.Library.GetUniqueName());
.ToDictionary(export => export.Library.Identity.Name);
var allSourceFiles = new List<string>(context.ProjectFile.Files.SourceFiles);
var allFileReferences = new List<string>();
var allProjectReferences = new List<ProjectReferenceDescription>();
@ -42,10 +43,8 @@ namespace Microsoft.DotNet.ProjectModel.Server
// All exports are returned. When the same library name have a ReferenceAssembly type export and a Package type export
// both will be listed as dependencies. Prefix "fx/" will be added to ReferenceAssembly type dependency.
foreach (var pair in allExports)
foreach (var export in allExports.Values)
{
var export = pair.Value;
allSourceFiles.AddRange(export.SourceReferences);
allFileReferences.AddRange(export.CompilationAssemblies.Select(asset => asset.ResolvedPath));

View file

@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.ProjectModel.Compilation;
using Microsoft.DotNet.ProjectModel.Graph;
using Microsoft.DotNet.ProjectModel.Server.Helpers;
namespace Microsoft.DotNet.ProjectModel.Server.Models
@ -54,27 +55,32 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models
public static DependencyDescription Create(LibraryDescription library,
List<DiagnosticMessage> diagnostics,
Dictionary<string, LibraryExport> allExports)
IDictionary<string, LibraryExport> exportsLookup)
{
var name = library.GetUniqueName();
return new DependencyDescription
{
Name = name,
Name = library.Identity.Name,
DisplayName = library.Identity.Name,
Version = library.Identity.Version?.ToNormalizedString(),
Type = library.Identity.Type.Value,
Resolved = library.Resolved,
Path = library.Path,
Dependencies = library.Dependencies.Select(dependency => new DependencyItem
{
Name = dependency.GetUniqueName(),
Version = allExports[dependency.GetUniqueName()].Library.Identity.Version?.ToNormalizedString()
}),
Dependencies = library.Dependencies.Select(dependency => GetDependencyItem(dependency, exportsLookup)),
Errors = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Error)
.Select(d => new DiagnosticMessageView(d)),
Warnings = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Warning)
.Select(d => new DiagnosticMessageView(d))
};
}
private static DependencyItem GetDependencyItem(LibraryRange dependency,
IDictionary<string, LibraryExport> exportsLookup)
{
return new DependencyItem
{
Name = dependency.Name,
Version = exportsLookup[dependency.Name].Library.Identity.Version?.ToNormalizedString()
};
}
}
}

View file

@ -43,7 +43,7 @@ namespace Microsoft.DotNet.ProjectModel.Server
catch (IOException ex)
{
// swallow
_log.LogWarning($"Ignore {nameof(IOException)} during sending message: \"{ex.Message}\".");
_log.LogInformation($"Ignore {nameof(IOException)} during sending message: \"{ex.Message}\".");
}
catch (Exception ex)
{
@ -79,7 +79,7 @@ namespace Microsoft.DotNet.ProjectModel.Server
}
catch (IOException ex)
{
_log.LogWarning($"Ignore {nameof(IOException)} during receiving messages: \"{ex}\".");
_log.LogInformation($"Ignore {nameof(IOException)} during receiving messages: \"{ex}\".");
}
catch (Exception ex)
{
@ -87,4 +87,4 @@ namespace Microsoft.DotNet.ProjectModel.Server
}
}
}
}
}