Replaced TupleComparer with CqlTupleTypeComparer. The new comparer compares value tuples where the first parameter is of type CqlTupleMetadata and uses the metadata to compare items.
The legacy TupleBaseTypeComparer cannot be removed yet, since some unit tests still execute against directly compiled LambdaExpressions, instead of going through the C# code writer and assembly compiled.
CqlTupleMetadata had to be moved to a more base project and was moved from Hl7.Cql.Runtime' toHl7.Cql.Primitives`
TypeExtensions had to move to a more base project too, and was moved from Hl7.Cql.Compiler to Hl7.Cql.Primitives. The extensions for this particular TypeExtensions is for types related to CQL.
Added unit test TypeExtensionsTests
Relevant unit tests from CoreTests were moved into subfolders so it is clear from which project they belong to
A few places in the repo uses a property-name/property-type tuple. Sometimes the type is placed first, other times the name. This was made consistent so the type is always first.
Integration Runner
While working on this PR, I also looked at the integration tests for CMS measure. I found they were flaky, due to the libraries sometimes failing to create. This was due to the CqlTupleMetadata calculating the hashcode in the constructor, and that used Hasher.Instance which uses MD5 to hash a string. For some strange reason, a NullReferenceException is sometimes thrown deep inside the stack trace. I changed the CqlTupleMetadata to do hash calculation lazily.
I also discovered that the KeyValuePairComparer<TKey,TValue> comparer fails when TValue is an object when doing a compare. An error is thrown stating that 'object' is not comparable. I fixed this by using the ICqlComparer on key and value instead.
Fix for
613
Work
TupleComparer
withCqlTupleTypeComparer
. The new comparer compares value tuples where the first parameter is of typeCqlTupleMetadata
and uses the metadata to compare items.TupleBaseTypeComparer
cannot be removed yet, since some unit tests still execute against directly compiled LambdaExpressions, instead of going through the C# code writer and assembly compiled.CqlTupleMetadata
had to be moved to a more base project and was moved fromHl7.Cql.Runtime' to
Hl7.Cql.Primitives`TypeExtensions
had to move to a more base project too, and was moved fromHl7.Cql.Compiler
toHl7.Cql.Primitives
. The extensions for this particularTypeExtensions
is for types related to CQL.TypeExtensionsTests
Integration Runner
While working on this PR, I also looked at the integration tests for CMS measure. I found they were flaky, due to the libraries sometimes failing to create. This was due to the CqlTupleMetadata calculating the hashcode in the constructor, and that used Hasher.Instance which uses MD5 to hash a string. For some strange reason, a NullReferenceException is sometimes thrown deep inside the stack trace. I changed the
CqlTupleMetadata
to do hash calculation lazily.I also discovered that the
KeyValuePairComparer<TKey,TValue>
comparer fails whenTValue
is anobject
when doing a compare. An error is thrown stating that 'object' is not comparable. I fixed this by using the ICqlComparer on key and value instead.Test pass rate increased from 68% to 72%