Table of Contents

Struct DotNetRuntimeInfo

Namespace
AsmResolver.DotNet
Assembly
AsmResolver.DotNet.dll

Provides information about a target runtime.

public readonly struct DotNetRuntimeInfo : IEquatable<DotNetRuntimeInfo>
Implements
Inherited Members

Constructors

DotNetRuntimeInfo(string, Version)

Creates a new instance of the DotNetRuntimeInfo structure.

public DotNetRuntimeInfo(string name, Version version)

Parameters

name string

The name of the runtime.

version Version

The version of the runtime.

Fields

NetCoreAppName

The target framework name used by applications targeting .NET or .NET Core.

public const string NetCoreAppName = ".NETCoreApp"

Field Value

string

NetCoreName

A target framework name used in some legacy architectures.

public const string NetCoreName = ".NETCore"

Field Value

string

Remarks

This should not be confused with NetCoreName, which is the correct name for applications targeting .NET or .NET Core.

NetFrameworkName

The target framework name used by applications targeting legacy .NET Framework.

public const string NetFrameworkName = ".NETFramework"

Field Value

string

NetPortableName

The target framework name used by applications targeting legacy .NET Portable.

public const string NetPortableName = ".NETPortable"

Field Value

string

NetStandardName

The target framework name used by libraries targeting .NET Standard.

public const string NetStandardName = ".NETStandard"

Field Value

string

Properties

IsNetCore

Gets a value indicating whether or not the application is targeting a legacy architecture that uses .NET Core (.NET Native).

public bool IsNetCore { get; }

Property Value

bool

Remarks

This should not be confused with IsNetCoreApp, which is the correct property for whether or not an application is targeting .NET or .NET Core.

IsNetCoreApp

Gets a value indicating whether the application targets the .NET or .NET Core runtime or not.

public bool IsNetCoreApp { get; }

Property Value

bool

IsNetFramework

Gets a value indicating whether the application targets the .NET Framework runtime or not.

public bool IsNetFramework { get; }

Property Value

bool

IsNetPortable

Gets a value indicating whether the application targets the .NET Portable runtime or not.

public bool IsNetPortable { get; }

Property Value

bool

IsNetStandard

Gets a value indicating whether the application targets the .NET standard specification or not.

public bool IsNetStandard { get; }

Property Value

bool

Name

Gets the name of the runtime.

public string Name { get; }

Property Value

string

Version

Gets the version of the runtime.

public Version Version { get; }

Property Value

Version

Methods

Equals(DotNetRuntimeInfo)

public bool Equals(DotNetRuntimeInfo other)

Parameters

other DotNetRuntimeInfo

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetAssumedImplCorLib()

Obtains a reference to the assumed implementation core lib for this runtime.

public AssemblyReference? GetAssumedImplCorLib()

Returns

AssemblyReference

The reference to the assumed implementation core lib.

Exceptions

ArgumentException

The runtime information is invalid or unsupported.

GetDefaultCorLib()

Obtains a reference to the default core lib of this runtime.

public AssemblyReference GetDefaultCorLib()

Returns

AssemblyReference

The reference to the default core lib.

Exceptions

ArgumentException

The runtime information is invalid or unsupported.

GetHashCode()

public override int GetHashCode()

Returns

int

NetCoreApp(int, int)

Constructs a runtime info record referencing .NET Standard.

public static DotNetRuntimeInfo NetCoreApp(int major, int minor)

Parameters

major int

The major version

minor int

The minor version

Returns

DotNetRuntimeInfo

The runtime info record.

NetCoreApp(int, int, int)

Constructs a runtime info record referencing .NET Standard.

public static DotNetRuntimeInfo NetCoreApp(int major, int minor, int patch)

Parameters

major int

The major version

minor int

The minor version

patch int

The patch version

Returns

DotNetRuntimeInfo

The runtime info record.

NetCoreApp(Version)

Constructs a runtime info record referencing .NET Core and .NET.

public static DotNetRuntimeInfo NetCoreApp(Version version)

Parameters

version Version

The version

Returns

DotNetRuntimeInfo

The runtime info record.

NetFramework(int, int)

Constructs a runtime info record referencing legacy .NET Framework.

public static DotNetRuntimeInfo NetFramework(int major, int minor)

Parameters

major int

The major version

minor int

The minor version

Returns

DotNetRuntimeInfo

The runtime info record.

NetFramework(int, int, int)

Constructs a runtime info record referencing legacy .NET Framework.

public static DotNetRuntimeInfo NetFramework(int major, int minor, int patch)

Parameters

major int

The major version

minor int

The minor version

patch int

The patch version

Returns

DotNetRuntimeInfo

The runtime info record.

NetFramework(Version)

Constructs a runtime info record referencing legacy .NET Framework.

public static DotNetRuntimeInfo NetFramework(Version version)

Parameters

version Version

The version

Returns

DotNetRuntimeInfo

The runtime info record.

NetStandard(int, int)

Constructs a runtime info record referencing .NET Standard.

public static DotNetRuntimeInfo NetStandard(int major, int minor)

Parameters

major int

The major version

minor int

The minor version

Returns

DotNetRuntimeInfo

The runtime info record.

NetStandard(Version)

Constructs a runtime info record referencing .NET Standard.

public static DotNetRuntimeInfo NetStandard(Version version)

Parameters

version Version

The version

Returns

DotNetRuntimeInfo

The runtime info record.

Parse(string)

Parses the framework name as provided in a System.Runtime.Versioning.TargetFrameworkAttribute attribute.

public static DotNetRuntimeInfo Parse(string frameworkName)

Parameters

frameworkName string

The full runtime name.

Returns

DotNetRuntimeInfo

The parsed version info.

ParseMoniker(string)

Parses the target framework moniker as provided in a .runtimeconfig.json file.

public static DotNetRuntimeInfo ParseMoniker(string moniker)

Parameters

moniker string

The moniker

Returns

DotNetRuntimeInfo

The parsed version info.

ToString()

public override string ToString()

Returns

string

TryParse(string, out DotNetRuntimeInfo)

Attempts to parse the framework name as provided in a System.Runtime.Versioning.TargetFrameworkAttribute attribute.

public static bool TryParse(string frameworkName, out DotNetRuntimeInfo info)

Parameters

frameworkName string

The full runtime name.

info DotNetRuntimeInfo

The parsed version info.

Returns

bool

true if the provided name was in the correct format, false otherwise.

TryParseMoniker(string, out DotNetRuntimeInfo)

Attempts to parse the target framework moniker as provided in a .runtimeconfig.json file.

public static bool TryParseMoniker(string moniker, out DotNetRuntimeInfo info)

Parameters

moniker string

The moniker

info DotNetRuntimeInfo

The parsed version info.

Returns

bool

true if the provided name was in the correct format, false otherwise.