- VSIX Release 2.1 developed with (and for) VS 2019; installer available at Visual Studio Marketplace.
- Fixed a bug in Man.UnitsOfMeasurement.Parser that could make it hang in an infinite loop trying to unravel certain (not necessarily weird) relationships between units.
-
unit and scale templates moved to external files (_unit.t4 and _scale.t4 correspondingly) to be used in generators as T4 include files.
-
newer C# syntax used in templates (though not the latest one that requires Roslyn compiler). RuntimeLoader still uses the old csc compiler that does not accept the latest syntax (that is possible to employ Roslyn in RuntimeLoader but the number and size of NuGet packages required for this is overwhelming and makes me skeptical about this approach).
-
static properties have been replaced by constants or static readonly fields:
public static readonly Dimension Sense = ...;
public const int Family = ...;
public static readonly SymbolCollection Symbol = ...;
public static readonly Unit<double> Proxy = ...;
public const double Factor = ...;
// except Factor for monetary units (only):
public static decimal Factor { get; set; }
// and Format that remains gettable/settable property for all units:
public static string Format { get; set; }
- new method to format value types (float, double, decimal) into a string with a unit tag prepended/appended:
// for units:
static string String(<valuetype> q, string format, IFormatProvider fp)
// and scales:
static string String(<valuetype> q, string format, IFormatProvider fp)
// For example:
// Meter.String(123.45) -> "123.45 m"
// Fahrenheit.String(123.45) -> "123.45 deg.F"
-
Unit/_dimensional_analysis.include: C# file created (while generating units/scales) to facilitate a transition from calculations based on measured quantities to (faster) calculations on plain numbers. The transition is intended to be performed within the same source code (possibly) supplemented with conditional statements. Alas, C# does not support include-files functionality! Shit happens! So, if you decide to make use of the generated file you have to include it "by hand". Take a look at BulletMeasured.cs sample to see how the transition can be made.
-
Unit/Math.cs (static file, independent of generators): could provide basic math expressions on measured quantities (e.g.
Sin(Radian)
,Cos(Radian)
etc.). Initially empty (provides nothing): it is up to you to decide its content.
- Demo/Bullet: new sample application that is doing (basically) the same as Demo/ProjectileRange but is more accurate on time measurement and thus provides more reliable benchmarks.
- Demo/Benchmark: now it employs BenchmerkDotNet framework to get more accurate and reliable results.
-
VSIX Release 2.0 for VS 2017 available at Visual Studio Marketplace.
-
VSIX Release 2.0 for VS 2010-2015 available at Visual Studio Marketplace (final release for VS 2010).
- Unit<T> and Scale<T> proxies have been redesigned to eliminate Reflection mechanism. Now the proxies are all generated from _generator.tt template together with the corresponding units and scales. In effect, usage of Reflection has been reduced to a minimum: for compile-time units/scales it is not used at all, while for run-time (late) units it is used only to retrieve the proxies from an intermediate DLL, but never used when operating them.
- IQuantity<T> (ILevel<T>) instance provides access to the whole Unit<T> unit proxy (Scale<T> scale proxy) correspondingly (and not to its selected properties only as previously).
-
Single, static Catalog class (for all unit and scale proxies of any type) replaces previous Unit- and Scale-Catalog<T> classes heavily using Reflection. The Catalog is partially generated from _generator.tt template (to populate it with units specified in a definition text file) and is available as a whole in Units solution folder at compile-time.
-
Parser solution folder has replaced Catalog folder. It contains just a few classes providing parsing functionality previously offered by UnitCatalog<T> and ScaleCatalog<T> classes.
- New conversion functions to ease interpreting quantity as a level (or attaching quantity to a scale). Their goal is to defer issues resulting from distinguishing levels and quantities to a moment when the distinction is really essential and thus, focus on quantities as a basic processing entities:
// Fahrenheit scale (for example)
public static Fahrenheit From(IQuantity<double> q)
// Scale<T> proxy
public abstract ILevel<T> From(IQuantity<T> quantity);
- Unit symbols handled as case-sensitive strings only. The mechanism that allowed previously to switch between case-sensitive and case-insensitive interpretation has been removed.
- SymbolCollection.Default property introduced to avoid indexer expression Symbol[0] e.g.:
Meter.Symbol.Default // instead of Meter.Symbol[0]
- Wedge product: wedge operator "^" can be applied to multiply units (only) apart from the standard star operator "*". This allows to make a distinction between scalar (*) and vector (^) products that create different units from the same factors, for example:
unit Joule "J" = Newton * Meter; /*energy*/
unit NewtonMeter "N*m" = Newton ^ Meter; /*torque*/
-
Validating scales: scales (within a single family) must be derived from different units, otherwise they are deemed indistinguishable and rejected.
-
Validating unit symbols: unit symbols must be unique. No two units can use the same (case sensitively) symbol.
-
Parser diagnostics improved: more meaningfull, less misleading error messages.
-
Extended interfaces IQuantity<T> and ILevel<T>. Now unit and scale properties (Family, Factor etc.) can be accessed directly, via IQuantity<T> or ILevel<T> interfaces, without referring to Reflection-based and performance (very) costly proxy types: Unit<T> and Scale<T>.
-
Delegates applied in Unit<T> and Scale<T> proxies. This significantly enhance the performance of the proxy-types (previously operating via pure Reflection). Creation (constructor) of a proxy-type is still Reflection-based and costly but usage of (a previously created) proxy is much (hundreds of times) faster than previously.
-
UnitCatalog[] and ScaleCatalog[] indexers extended.
-
Benchmark demo enhanced: averages calculated for all operations, all averages calculated with a standard deviation.
-
.Net Framework Client Profile abandoned. Only full .Net Framework Profile is used.
-
Removed redundant namespace reference in RuntimeLoader.Decompiler.
internal
access form_value
&m_level
fields in unit & scale structs. Access modifier form_value
&m_level
fields changed fromprivate
tointernal
. This allows to access these fields directly (not viaValue
&Level
properties), and consequently, results in faster quantity arithmethic.Demo/Benchmark
shows (under VS2010) that unit/plain arithmetic performance ratio decreased to about 1.3 versus 1.6 in previous version, with private fields.- One (unified)
_generator.tt
template that can generate units both in a single .cs file as well as in multiple .cs files (one for each unit). Output mode depends on boolean variable__one_cs_file
(declared within _generator.tt). Set:__one_cs_file = true;
to generate all units in a single file (default), or:__one_cs_file = false;
to generate units in separate files. - Replaced icon & preview images for the project template & VSIX.
- Removed VSIX constraint on the
MaxVersion
of the .NET Framework that can be used with the library. AssemblyFileVersion
for internal subprojects changes only when source files change (and not with every build).
- fix #3: Unit family not recognized due to parenthesized dimensional expressions.
- fix #2 (again): "Run Custom Tool" performing very slow on
_generator.tt
under VS 2015. The generator has been modified to generate all units and scales in a single .cs file (instead of separate .cs files, one for each unit/scale). Under VS2015, it is somehow easier to recreate class-view subitems attached to a single .cs file than recreate the same class-views attached to many separate .cs files. You can restore previous functionality by replacing_generator.tt
with_generator-multiplefiles.tt
from the archive_alternative_generators_readme.zip
that you can find attached to newly created projects.
- fix #1: CSharpCodeProvider not Disposed() in RuntimeLoader.Compiler.
- fix #2: "Run Custom Tool" performing very slow under VS 2015.
- VSIX manifest (extension.vsixmanifest) extended to support VS 2015 and .NET Framework 4.6.
- RuntimeLoader functionality to load (late) units and scales from a definition text file at runtime.
- RuntimeUnits sample application as a RuntimeLoader demo.
- As of VS Community edition it does not make sense to support VS Express editions.
- Static properties of unit (Sense, Family, Factor, Format, Symbol) and scale (Offset, Format) are no longer dragged behind each of their instances (as properties of quantities and levels).
- These properties are still available via proxy types: Unit<T> and Scale<T> i.e. via reflection, which is slow but this impacts only performance of the "generic" conversion method "From".
- You can safely restore previous functionality (by restoring the interfaces and properties in unit and scale templates as it was in Release 1.0).
- Test settings (previously .gitignored) now included back into the repository.
- All catalog-related functionality moved to Catalog subfolder.
- UnitProxy replaced by (abstract) Measure and its subclasses: either Unit<T> or Scale<T> types, representing (correspondingly) unit and scale proxy types (T=double|decimal|float).
- UnitCatalog replaced by UnitCatalog<T> for cataloging Unit<T> proxies and parsing text input into IQuantity<T>.
- Added ScaleCatalog<T> (as twin of UnitCatalog<T>) for cataloging Scale<T> proxies and parsing text input into ILevel<T>.
- Scale definition syntax extended to distinguish scale families bound to different reference levels but derived from the same units. E.g. two temperature scale families: one bound to absolute zero level and the other one to water freeze point. The new syntax allows to specify the name (identifier) of the reference level, that is common to all members of the family.
- Scales defined with this new syntax receive ScaleReferencePointAttribute specifying the name of the family common reference level.
- Units/scales ToString methods rearranged to conform to IFormattable interface.
- Family is no longer initialized by the parser. That is set within _generator.tt template (being under user control).
- Number.ToString methods of precision greater than the default (15 digits for doubles)
- UnitTypes and ScaleTypes collections (not very useful) replaced by standard List<UnitType> and List<ScaleType>.
- Superfluous namespace handling removed in UnitType and ScaleType.
- The constants implemented in a better way (but functionally left unchanged).
- Create README.md
- Copy LICENSE.txt