Converter.Temperature
3.2.50
Prefix Reserved
dotnet add package Converter.Temperature --version 3.2.50
NuGet\Install-Package Converter.Temperature -Version 3.2.50
<PackageReference Include="Converter.Temperature" Version="3.2.50" />
paket add Converter.Temperature --version 3.2.50
#r "nuget: Converter.Temperature, 3.2.50"
// Install Converter.Temperature as a Cake Addin #addin nuget:?package=Converter.Temperature&version=3.2.50 // Install Converter.Temperature as a Cake Tool #tool nuget:?package=Converter.Temperature&version=3.2.50
README
Converter.Temperature This project was created to extract out the main conversion code from the Temperature Converter applications in the other repositories. I am using this as a way to show how my development skills have changed over the years, as I get to be a better developer.
Introduction
These extension methods will convert different types of temperatures to other types.
Temperature types
- Celsius
- Fahrenheit
- Kelvin
- Gas
- Rankine
- Rømer
Data types
- int
- long
- float
- double
- string
Ideas
I had a few ideas on how to do the extension methods but decided on using a fluent style.
Originally, the extensions looked like this:
var tempToConvert = 34; // an int.
var convertedTemp = tempToConvert.CelsiusToFahrenheit();
Then I thought that this looked a bit naf so, I went with setting up the from first, then the to. This follows the fluent pattern.
Now it is used like this:
var tempToConvert = 34; // an int.
var convertedTemp = tempToConvert.FromCelsius().ToFahrenheit();
The next stage for version 2 is to add an additional usage like this:
var tempToConvert = 34; // an int.
var convertedTemp = tempToConvert.From<Celsius>().To<Fahrenheit>();
What to do for edge cases
I'm working on what I want the library to do when an exception could be thrown. This is when we have the edge cases of values that are too small or too large for the type being converted to.
E.g.:
From a float type with a value close to the max value of a float, converted from Celsius to Fahrenheit. Because a Fahrenheit value is greater than the celsius value, then we can't convert correctly.
Should this throw an exception or just return the original value?
Well, returning the same value would seem like all is well, even though the converted value is wrong. Thinking about this means that for me, it should throw an exception for the calling application to handle.
If anyone has any better ideas, then I would be willing to change this behaviour.
More Information
For more information on the project and where it is heading, see the wiki.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers (>= 0.4.421302)
-
net7.0
- Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers (>= 0.4.421302)
-
net8.0
- Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers (>= 0.4.421302)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
See the details at the following link.
https://github.com/Daeer-Projects/Converter.Temperature/wiki/Release-Notes
Pay particular attention to the changes made for Issue 60 in the release notes.