Skip to content

v4.1.3 release #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
13 changes: 5 additions & 8 deletions src/ReadableExpressions/ReadableExpressions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<NetStandardImplicitPackageVersion Condition=" '$(TargetFramework)' == 'netstandard1.0' ">1.6.1</NetStandardImplicitPackageVersion>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.0' ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback>

<AssemblyVersion>4.1.2.0</AssemblyVersion>
<FileVersion>4.1.2.0</FileVersion>
<VersionPrefix>4.1.2</VersionPrefix>
<Version>4.1.2</Version>
<AssemblyVersion>4.1.3.0</AssemblyVersion>
<FileVersion>4.1.3.0</FileVersion>
<VersionPrefix>4.1.3</VersionPrefix>
<Version>4.1.3</Version>

<PackageId>AgileObjects.ReadableExpressions</PackageId>
<Title>AgileObjects.ReadableExpressions</Title>
Expand All @@ -26,10 +26,7 @@
<PackageIcon>./Icon.png</PackageIcon>
<PackageTags>ExpressionTrees Debugging DebuggerVisualizers Linq DLR</PackageTags>
<PackageProjectUrl>https://github.com/AgileObjects/ReadableExpressions</PackageProjectUrl>
<PackageReleaseNotes>- Fixing nullable enum translation, re: #134
- Improving ShowCapturedValues capabilities to include captured Linq calls, re: #133
- Fixing parameterless Value Tuple translation, re: #135
- Fixing non-equality enum comparisons, re: #136
<PackageReleaseNotes>- Fixing binary operand type-is checks, re: #142
</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageOutputPath>../../NuGet</PackageOutputPath>
Expand Down
2 changes: 1 addition & 1 deletion src/ReadableExpressions/Translations/BinaryTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private static bool IsEnumType(
Expression expression,
out Expression enumExpression)
{
if (expression.NodeType.IsCast())
if (expression.NodeType.IsConversion())
{
expression = expression.GetUnaryOperand();
}
Expand Down
13 changes: 11 additions & 2 deletions src/ReadableExpressions/Translations/CastTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,20 @@ public static bool IsCast(ExpressionType nodeType)
{
return nodeType switch
{
ExpressionType.Convert => true,
ConvertChecked => true,
TypeAs => true,
TypeIs => true,
Unbox => true,
_ when IsConversion(nodeType) => true,
_ => false
};
}

public static bool IsConversion(ExpressionType nodeType)
{
return nodeType switch
{
ExpressionType.Convert => true,
ConvertChecked => true,
_ => false
};
}
Expand Down
3 changes: 3 additions & 0 deletions src/ReadableExpressions/Translations/TranslationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public static bool IsCast(this INodeTranslation translation)
public static bool IsCast(this ExpressionType nodeType)
=> CastTranslation.IsCast(nodeType);

public static bool IsConversion(this ExpressionType nodeType)
=> CastTranslation.IsConversion(nodeType);

public static INodeTranslation WithParentheses(
this INodeTranslation translation)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ public void ShouldTranslateAnAsCastExpression()
translated.ShouldBe("stream as IDisposable");
}

[Fact]
public void ShouldTranslateAnIsTypeExpression()
{
var objectIsDisposable = CreateLambda((object o) => o is IDisposable);

var translated = objectIsDisposable.Body.ToReadableString();

translated.ShouldBe("o is IDisposable");
}

// See https://github.com/agileobjects/ReadableExpressions/issues/142
[Fact]
public void ShouldTranslateAnIsTypeExpressionOperand()
{
var intValueAndIsTypeChecks =
CreateLambda((int i, object o) => i == 1 && o is string);

var translated = intValueAndIsTypeChecks.Body.ToReadableString();

translated.ShouldBe("(i == 1) && (o is string)");
}

[Fact]
public void ShouldTranslateABoxingExpression()
{
Expand Down Expand Up @@ -168,7 +190,7 @@ public void ShouldTranslateExplicitUnaryConversionWithCustomStaticMethod()
typeof(bool),
typeof(Convert).GetMethod("IsDBNull")));

var translated =
var translated =
objectToBoolWithIsDbNullLambda.ToReadableString();

translated.ShouldBe("() => Convert.IsDBNull(null)");
Expand Down
Loading