Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondřej Štorc committed Sep 21, 2020
1 parent 92a4965 commit 414616b
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 36 deletions.
17 changes: 5 additions & 12 deletions src/Tasks.UnitTests/AssemblyDependency/Miscellaneous.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3304,18 +3304,14 @@ public void ParentAssemblyResolvedFromAForGac()
Assert.Single(parentReferenceFolders);
Assert.Equal(reference2.ResolvedSearchPath, parentReferenceFolders[0]);
}

/// <summary>
/// Generate a fake reference which has been resolved from the gac. We will use it to verify the creation of the exclusion list.
/// </summary>
/// <returns></returns>
private ReferenceTable GenerateTableWithAssemblyFromTheGlobalLocation(string location)
{
ReferenceTable referenceTable = new ReferenceTable(null, false, false, false, false, new string[0], null, null, null, null, null, null, SystemProcessorArchitecture.None, fileExists, null, null, null, null, null,
#if FEATURE_WIN32_REGISTRY
null, null, null,
#endif
null, null, new Version("4.0"), null, null, null, true, false, null, null, false, null, WarnOrErrorOnTargetArchitectureMismatchBehavior.None, false, false, null);
ReferenceTable referenceTable = MakeEmptyReferenceTable(null);

AssemblyNameExtension assemblyNameExtension = new AssemblyNameExtension(new AssemblyName("Microsoft.VisualStudio.Interopt, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
TaskItem taskItem = new TaskItem("Microsoft.VisualStudio.Interopt, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
Expand Down Expand Up @@ -5939,7 +5935,7 @@ public void RedistListNoAssembliesinRedistList()
[Fact]
public void RedistListGenerateBlackListGoodListsSubsetIsSubsetOfRedist()
{
string redistFile = CreateGenericRedistList();
string redistFile = CreateGenericRedistList();
string goodSubsetFile = FileUtilities.GetTemporaryFile();
try
{
Expand Down Expand Up @@ -6775,11 +6771,8 @@ public void ReferenceTableDependentItemsInBlackList3()
[Fact]
public void ReferenceTableDependentItemsInBlackList4()
{
ReferenceTable referenceTable = new ReferenceTable(null, false, false, false, false, new string[0], null, null, null, null, null, null, SystemProcessorArchitecture.None, fileExists, null, null, null, null,
#if FEATURE_WIN32_REGISTRY
null, null, null,
#endif
null, null, null, new Version("4.0"), null, null, null, true, false, null, null, false, null, WarnOrErrorOnTargetArchitectureMismatchBehavior.None, false, false, null);
ReferenceTable referenceTable = MakeEmptyReferenceTable(null);

MockEngine mockEngine;
ResolveAssemblyReference rar;
Dictionary<string, string> blackList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using MessagePack;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using MessagePack;
using Microsoft.Build.Framework;
using Microsoft.Build.Tasks.ResolveAssemblyReferences;
using Microsoft.Build.Tasks.ResolveAssemblyReferences.Client;
Expand All @@ -10,11 +15,6 @@
using Microsoft.Build.Utilities;
using Nerdbank.Streams;
using Shouldly;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using Xunit;
using Xunit.Abstractions;
using Task = System.Threading.Tasks.Task;
Expand Down Expand Up @@ -77,6 +77,33 @@ public void TransferredResponseEquals()
ResolveAssemblyReferenceComparer.CompareOutput(response, responseDes).ShouldBeTrue();
}

[Fact]
public void RarOutputPropertyTest()
{
ResolveAssemblyReferenceResponse expectedResponse = GetPopulatedObject<ResolveAssemblyReferenceResponse>("test", new[] { "testArr" }, true, new[] { new ReadOnlyTaskItem("test") });

ResolveAssemblyReference rar = new ResolveAssemblyReference();
rar.ResolveAssemblyReferenceOutput = expectedResponse;
ResolveAssemblyReferenceResponse response = rar.ResolveAssemblyReferenceOutput;

ResolveAssemblyReferenceComparer.CompareOutput(expectedResponse, response).ShouldBeTrue();
}

[Fact]
public void RarIputPropertyTest()
{
ResolveAssemblyReferenceRequest expectedRequest = GetPopulatedObject<ResolveAssemblyReferenceRequest>("test", new[] { "testArr" }, true, new[] { new ReadOnlyTaskItem("test") });
expectedRequest.CurrentPath = Directory.GetCurrentDirectory();
expectedRequest.WarnOrErrorOnTargetArchitectureMismatch = "None"; // Serialized into enum, so we have to provide correct value

ResolveAssemblyReference rar = new ResolveAssemblyReference();
rar.ResolveAssemblyReferenceInput = expectedRequest;
ResolveAssemblyReferenceRequest request = rar.ResolveAssemblyReferenceInput;

ResolveAssemblyReferenceComparer.CompareInput(expectedRequest, request).ShouldBeTrue();
}


[Fact]
public void TransmitDataTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;

using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
using Microsoft.Build.Tasks;
using Microsoft.Build.Tasks.AssemblyDependency;
using Microsoft.Build.Tasks.ResolveAssemblyReferences.Contract;
using Microsoft.Build.Tasks.ResolveAssemblyReferences.Server;
using Microsoft.Build.Tasks.ResolveAssemblyReferences.Services;
using Microsoft.Build.Utilities;
using Microsoft.Win32;
using FrameworkNameVersioning = System.Runtime.Versioning.FrameworkName;
using SystemProcessorArchitecture = System.Reflection.ProcessorArchitecture;
using Nerdbank.Streams;
using Xunit;
using Xunit.Abstractions;
using Shouldly;
using Nerdbank.Streams;
using Microsoft.Build.Tasks.ResolveAssemblyReferences.Server;
using Microsoft.Build.Tasks.ResolveAssemblyReferences.Contract;
using System.Threading.Tasks;
using System.Threading;
using Microsoft.Build.Tasks.ResolveAssemblyReferences.Services;
using FrameworkNameVersioning = System.Runtime.Versioning.FrameworkName;
using SystemProcessorArchitecture = System.Reflection.ProcessorArchitecture;
using Task = System.Threading.Tasks.Task;

namespace Microsoft.Build.UnitTests.ResolveAssemblyReference_Tests
{
Expand Down Expand Up @@ -2988,7 +2988,7 @@ public void Dispose()

public Task<ResolveAssemblyReferenceResult> ExecuteAsync(ResolveAssemblyReferenceRequest input, CancellationToken cancellationToken = default)
{
return System.Threading.Tasks.Task.FromResult(Execute(input));
return Task.FromResult(Execute(input));
}

internal ResolveAssemblyReferenceResult Execute(ResolveAssemblyReferenceRequest input)
Expand Down
8 changes: 4 additions & 4 deletions src/Tasks/AssemblyDependency/AssemblyFoldersResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ internal class AssemblyFoldersResolver : Resolver
/// <summary>
/// Construct.
/// </summary>
/// <param name="searchPathElement">The search path element.</param>
/// <param name="getAssemblyName">Delegate to get the assembly name object.</param>
/// <param name="fileExists">Delegate to check if the file exists.</param>
/// <param name="searchPathElement">The corresponding element from the search path</param>
/// <param name="getAssemblyName">Delegate that gets the assembly name.</param>
/// <param name="fileExists">Delegate that returns if the file exists.</param>
/// <param name="getRuntimeVersion">Delegate to get the runtime version.</param>
/// <param name="targetedRuntimeVesion">The targeted runtime version.</param>
/// <param name="targetedRuntimeVesion">>Delegate that returns the clr runtime version for the file.</param>
public AssemblyFoldersResolver(string searchPathElement, GetAssemblyName getAssemblyName, FileExists fileExists, GetAssemblyRuntimeVersion getRuntimeVersion, Version targetedRuntimeVesion)
: base(searchPathElement, getAssemblyName, fileExists, getRuntimeVersion, targetedRuntimeVesion, System.Reflection.ProcessorArchitecture.None, false)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ public ReadOnlyTaskItem(string itemSpec, IDictionary metadata)
foreach (DictionaryEntry singleMetadata in metadata)
{
string key = (string)singleMetadata.Key;
if (key != null)
if (key == null)
{
MetadataNameToValue[key] = (string)singleMetadata.Value ?? string.Empty;
return;
}

MetadataNameToValue[key] = (string)singleMetadata.Value ?? string.Empty;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public async Task<int> StartAsync(CancellationToken cancellationToken = default)
{
return pipeServerStream;
}
Console.WriteLine("ERROR: Didn't validate handshake");

// We couldn't validate connection, so don't use this connection at all.
pipeServerStream.Dispose();
Expand Down

0 comments on commit 414616b

Please sign in to comment.