TargetFrameworkMoniker Class
Definition
- Namespace
- Cuemon.Reflection
- Assemblies
- Cuemon.Core.dll
Provides a set of static methods for resolving target framework monikers from assemblies and the current application context.
public static class TargetFrameworkMoniker
- Inheritance
-
objectTargetFrameworkMoniker
Examples
TargetFrameworkMoniker parses and resolves short target framework names such as net10.0, net9.0, netstandard2.0, and net481 from framework names, assemblies, paths, or the current application context.
using System;
using System.Reflection;
using Cuemon.Reflection;
namespace MyApp.Examples;
public class TargetFrameworkMonikerExample
{
public void Demonstrate()
{
var parsed = TargetFrameworkMoniker.Parse(".NETCoreApp,Version=v10.0");
var current = TargetFrameworkMoniker.ResolveCurrent();
var library = TargetFrameworkMoniker.Resolve(typeof(TargetFrameworkMonikerExample).Assembly);
var outputPath = TargetFrameworkMoniker.ResolveFromPath(AppContext.BaseDirectory);
Console.WriteLine($"Parsed TFM: {parsed}");
Console.WriteLine($"Current TFM: {current}");
Console.WriteLine($"Example assembly TFM: {library}");
Console.WriteLine($"Output path TFM: {outputPath}");
if (TargetFrameworkMoniker.TryResolve(Assembly.GetExecutingAssembly(), out var executingAssemblyTfm))
{
Console.WriteLine($"Executing assembly TFM: {executingAssemblyTfm}");
}
}
}
Methods
| Name | Description |
|---|---|
| Parse(FrameworkName) | Parses the specified |
| Parse(string) | Parses the specified |
| Resolve(Assembly) | Resolves the target framework moniker of the specified |
| ResolveCurrent() | Resolves the target framework moniker of the current application context. |
| ResolveFromPath(string) | Resolves the nearest target framework moniker found in the specified |
| TryParse(FrameworkName, out string) | Attempts to parse the specified |
| TryParse(string, out string) | Attempts to parse the specified |
| TryResolve(Assembly, out string) | Attempts to resolve the target framework moniker of the specified |
| TryResolveCurrent(out string) | Attempts to resolve the target framework moniker of the current application context. |
| TryResolveFromPath(string, out string) | Attempts to resolve the nearest target framework moniker found in the specified |