dotnet-installer/TestAssets/TestPackages/dotnet-dependency-context-test/Program.cs
Andrew Stanton-Nurse 803fef6a8b fix equality issue in DependencyContextLoader (#2379)
When checking if the provided assembly is the Entry Point Assembly, we
previously just checked if the AssemblyNames were equal, but it turns
out AssemblyName doesn't implement Equals, so it was using Reference
Equality, which fails. This change uses Assembly.Equals, which has an
Equals implementation that works.

Also adds some tests to ensure it's working.

This unblocks scenarios where the EntityFramework `dotnet-ef` command
was trying to read DependencyContext.Default but receiving a null
reference.
2016-04-08 15:33:32 -07:00

42 lines
1.2 KiB
C#

using System;
using System.Linq;
using Microsoft.Extensions.DependencyModel;
namespace Microsoft.DotNet.Tools.DependencyContextTest
{
public class Program
{
public static int Main(string[] args)
{
if(args.Length > 0 && args[0] == "--debug")
{
Console.WriteLine("Waiting for Debugger to attach, press ENTER to continue");
Console.WriteLine($"Process ID: {System.Diagnostics.Process.GetCurrentProcess().Id}");
Console.ReadLine();
}
if(DependencyContext.Default != null)
{
Console.WriteLine("DependencyContext.Default is set!");
}
else
{
Console.Error.WriteLine("DependencyContext.Default is NULL!");
return 1;
}
if(DependencyContext.Default.RuntimeGraph.Any())
{
Console.WriteLine("DependencyContext.Default.RuntimeGraph has items!");
}
else
{
Console.WriteLine("DependencyContext.Default.RuntimeGraph is empty!");
return 1;
}
Console.WriteLine("Tests succeeded!");
return 0;
}
}
}