Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't throw when an unknown / unsupported runtime is installed #1226

Merged
merged 1 commit into from
Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace NUnit.Engine.Internal.RuntimeFrameworks
{
internal static class NetCoreFrameworkLocator
{
static Logger log = InternalTrace.GetLogger(typeof(NetCoreFrameworkLocator));

public static IEnumerable<RuntimeFramework> FindDotNetCoreFrameworks()
{
List<Version> alreadyFound = new List<Version>();
Expand All @@ -22,7 +24,12 @@ public static IEnumerable<RuntimeFramework> FindDotNetCoreFrameworks()
if (TryGetVersionFromString(dirName, out newVersion) && !alreadyFound.Contains(newVersion))
{
alreadyFound.Add(newVersion);
yield return new RuntimeFramework(RuntimeType.NetCore, newVersion);
// HACK: Avoid Exception for an unknown version - see issue #1223
// Requires change in RuntimeFramework.GetClrVersionForFramework()
if (newVersion.Major <= 7)
yield return new RuntimeFramework(RuntimeType.NetCore, newVersion);
else
log.Error($"Found .NET {newVersion.ToString(2)}, which is not yet supported.");
}
}

Expand Down
1 change: 1 addition & 0 deletions src/NUnitEngine/nunit.engine.core/RuntimeFramework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public RuntimeFramework(RuntimeType runtime, Version version, string profile)
// Version 0.0 means any version so we can't deduce anything
if (version != DefaultVersion)
{
Debug.Assert(IsFrameworkVersion(version));
if (IsFrameworkVersion(version))
ClrVersion = GetClrVersionForFramework(version);
else
Expand Down
21 changes: 0 additions & 21 deletions src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,6 @@ private RuntimeFramework SelectRuntimeFrameworkInner(TestPackage package)
return targetFramework;
}


/// <summary>
/// Returns the best available framework that matches a target framework.
/// If the target framework has a build number specified, then an exact
/// match is needed. Otherwise, the matching framework with the highest
/// build number is used.
/// </summary>
public RuntimeFramework GetBestAvailableFramework(RuntimeFramework target)
{
RuntimeFramework result = target;

foreach (RuntimeFramework framework in _availableRuntimes)
if (framework.Supports(target))
{
if (framework.ClrVersion.Build > result.ClrVersion.Build)
result = framework;
}

return result;
}

/// <summary>
/// Use Mono.Cecil to get information about all assemblies and
/// apply it to the package using special internal keywords.
Expand Down