GithubHelp home page GithubHelp logo

doug-murphy / dougmurphy.targetframeworks.endoflife Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 60 KB

This NuGet package contains an API to help determine if your Target Framework Moniker is, or will soon be, end of life.

License: MIT License

C# 100.00%
tfm eol target framework moniker end of life

dougmurphy.targetframeworks.endoflife's Introduction

Nuget Version Nuget Downloads

Introduction

Knowing if your Target Framework Moniker (TFM) is End of Life (EOL) or not can be very important in certain circumstances. Maybe your company requires using supported target frameworks for compliance reasons, maybe you're publishing a NuGet package and want to make sure you're only supporting frameworks that Microsoft supports, or maybe you just want to make sure you're staying up-to-date. No matter the reason, this NuGet package can help you out with that.

Methods

GetAllEndOfLifeTargetFrameworkMonikers

By default, this method will get all TFMs that are currently EOL. Two overloads are provided where you can either pass in an explicit DateTime to get all TFMs that will be EOL by that date, or a TimeframeUnit with an amount to forecast out to a date relative to current date.

CheckTargetFrameworkForEndOfLife

This method takes in a singular TFM or semicolon-delimited pluralized TFM and returns back which one(s), if any, of them are currently EOL.

Example Usage

Checking if a specific TFM is EOL

using DougMurphy.TargetFrameworks.EndOfLife.Enums;
using DougMurphy.TargetFrameworks.EndOfLife.Helpers;
using DougMurphy.TargetFrameworks.EndOfLife.Models;
using System;
using System.Collections.Generic;

public void CheckIfSingleTfmIsEol() {
    var tfm = "net5.0";
    TargetFrameworkCheckResponse endOfLifeResults = TargetFrameworkEndOfLifeHelper.CheckTargetFrameworkForEndOfLife(tfm);

    if (endOfLifeResults.EndOfLifeTargetFrameworks.Count == 0) {
        //the specified TFM is not EOL
    }
    else {
        //the specified TFM is EOL
        foreach (KeyValuePair<string, DateTime> endOfLifeTargetFramework in endOfLifeResults.EndOfLifeTargetFrameworks) {
            Console.WriteLine($"{endOfLifeTargetFramework.Key} has an EOL date of {endOfLifeTargetFramework.Value}");
        }
    }
}

public void CheckIfAnyOfMultipleTfmIsEol() {
    var tfm = "net5.0;net45";
    TargetFrameworkCheckResponse endOfLifeResults = TargetFrameworkEndOfLifeHelper.CheckTargetFrameworkForEndOfLife(tfm);

    if (endOfLifeResults.EndOfLifeTargetFrameworks.Count == 0) {
        //none of the specified TFMs are EOL
    }
    else {
        //at least one of the specified TFMs are EOL
        foreach (KeyValuePair<string, DateTime> endOfLifeTargetFramework in endOfLifeResults.EndOfLifeTargetFrameworks) {
            Console.WriteLine($"{endOfLifeTargetFramework.Key} has an EOL date of {endOfLifeTargetFramework.Value}");
        }
    }
}

public void CheckIfSingleTfmIsEolWithinThreeMonths() {
    var tfm = "net5.0";
    TargetFrameworkCheckResponse endOfLifeResults = TargetFrameworkEndOfLifeHelper.CheckTargetFrameworkForEndOfLife(tfm, TimeframeUnit.Month, 3);

    if (endOfLifeResults.EndOfLifeTargetFrameworks.Count == 0) {
        //the specified TFM is not EOL
    }
    else {
        //the specified TFM is EOL
        foreach (KeyValuePair<string, DateTime> endOfLifeTargetFramework in endOfLifeResults.EndOfLifeTargetFrameworks) {
            Console.WriteLine($"{endOfLifeTargetFramework.Key} has an EOL date of {endOfLifeTargetFramework.Value}");
        }
    }
}

public void CheckIfAnyOfMultipleTfmIsEolWithinThreeMonths() {
    var tfm = "net5.0;net45";
    TargetFrameworkCheckResponse endOfLifeResults = TargetFrameworkEndOfLifeHelper.CheckTargetFrameworkForEndOfLife(tfm, TimeframeUnit.Month, 3);

    if (endOfLifeResults.EndOfLifeTargetFrameworks.Count == 0) {
        //none of the specified TFMs are EOL
    }
    else {
        //at least one of the specified TFMs are EOL
        foreach (KeyValuePair<string, DateTime> endOfLifeTargetFramework in endOfLifeResults.EndOfLifeTargetFrameworks) {
            Console.WriteLine($"{endOfLifeTargetFramework.Key} has an EOL date of {endOfLifeTargetFramework.Value}");
        }
    }
}

Getting a list of TFMs that are currently EOL, or will be within a specified forecasted timeframe

using DougMurphy.TargetFrameworks.EndOfLife.Enums;
using DougMurphy.TargetFrameworks.EndOfLife.Helpers;
using DougMurphy.TargetFrameworks.EndOfLife.Models;
using System;
using System.Collections.Generic;

public void GetAllTfmsThatAreEol() {
    TargetFrameworkCheckResponse endOfLifeResults = TargetFrameworkEndOfLifeHelper.GetAllEndOfLifeTargetFrameworkMonikers();

    foreach (KeyValuePair<string, DateTime> endOfLifeTargetFramework in endOfLifeResults.EndOfLifeTargetFrameworks) {
        Console.WriteLine($"{endOfLifeTargetFramework.Key} has an EOL date of {endOfLifeTargetFramework.Value}");
    }
}

public void GetAllTfmsThatAreEolWithinOneYear() {
    //Get all EOL TFMs that are currently EOL, or will be EOL within 1 year of current date.
    TargetFrameworkCheckResponse endOfLifeResults = TargetFrameworkEndOfLifeHelper.GetAllEndOfLifeTargetFrameworkMonikers(TimeframeUnit.Year, 1);

    foreach (KeyValuePair<string, DateTime> endOfLifeTargetFramework in endOfLifeResults.EndOfLifeTargetFrameworks) {
        Console.WriteLine($"{endOfLifeTargetFramework.Key} has an EOL date of {endOfLifeTargetFramework.Value}");
    }
}

Web API Host

If you don't have something set up to automatically update your NuGet packages, and you don't want to worry about updating this one as new TFMs and EOL dates are added, check out my API on GitHub for hassle-free updates!

dougmurphy.targetframeworks.endoflife's People

Contributors

dependabot[bot] avatar doug-murphy avatar

Watchers

 avatar  avatar

dougmurphy.targetframeworks.endoflife's Issues

Support forecasting in CheckTargetFrameworkForEndOfLife()

When checking a TFM, you may want to know if that TFM is EOL within a specific forecasted date. You can work around this limitation right now by using the GetAllEndOfLifeTargetFrameworkMonikers() method and finding if your TFM is in the response, but that experience isn't very ideal.

Proposal is to add a method with signature CheckTargetFrameworkForEndOfLife(string rawTfm, TimeframeUnit timeframeUnit, byte timeframeAmount)

Return EOL date with TFM

Sometimes it may be required to know the date that a particular TFM goes EOL instead of simply knowing just that it is EOL. The EOL date for the TFM should be included in the response from the method.

Proposal is to change TargetFrameworkCheckResponse to have a IDictionary<string, DateTime> return type instead of IReadOnlyList<string> where the string key is the TFM and the DateTime value is the EOL date.

Update incorrect EOL dates

It seems that Microsoft made some minor changes to EOL dates for some frameworks since initial launch. We need to get these dates corrected.

The dates listed for .NET Core 3.1 EOL are incorrect. The NuGet package currently lists December 3, 2022. The actual EOL date for .NET Core 3.1 is December 13, 2022.

The dates listed for .NET 5 EOL are incorrect. The NuGet package currently lists May 8, 2022. The actual EOL date for .NET 5 is May 10, 2022.

The dates listed for .NET 6 EOL are incorrect. The NuGet package currently lists November 8, 2024. The actual EOL date for .NET 6 is November 12, 2024.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.