Skip to content
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
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@

### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|-----------------------------------------------
EFP0007 | Design | Error | Unsupported pattern in projectable expression

8 changes: 8 additions & 0 deletions src/EntityFrameworkCore.Projectables.Generator/Diagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,13 @@ public static class Diagnostics
DiagnosticSeverity.Error,
isEnabledByDefault: true);

public static readonly DiagnosticDescriptor UnsupportedPatternInExpression = new DiagnosticDescriptor(
id: "EFP0007",
title: "Unsupported pattern in projectable expression",
messageFormat: "The pattern '{0}' cannot be rewritten into an expression tree. Simplify the pattern or restructure the projectable member body.",
category: "Design",
DiagnosticSeverity.Error,
isEnabledByDefault: true);

}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_Extensions_IsInRange_P0_Foo_Entity
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, bool>> Expression()
{
return (global::Foo.Entity entity) => entity.Value >= 1 && entity.Value <= 100 ? true : false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_Extensions_IsNull_P0_Foo_Entity
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, bool>> Expression()
{
return (global::Foo.Entity entity) => entity == null ? true : false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_Extensions_IsNotNull_P0_Foo_Entity
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, bool>> Expression()
{
return (global::Foo.Entity entity) => !(entity == null) ? true : false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_Extensions_IsTerminal_P0_Foo_Entity
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, bool>> Expression()
{
return (global::Foo.Entity entity) => entity.Status == "Cancelled" || entity.Status == "Completed" ? true : false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_Extensions_GetComplexCategory_P0_Foo_Entity
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, string>> Expression()
{
return (global::Foo.Entity entity) => entity != null && entity.IsActive == true && entity.Value > 100 ? "Active High" : "Other";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_Extensions_GetCategory_P0_Foo_Entity
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, string>> Expression()
{
return (global::Foo.Entity entity) => entity.Value > 100 ? "High" : "Low";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// <auto-generated/>
#nullable disable
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_Entity_IsInRange
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, bool>> Expression()
{
return (global::Foo.Entity @this) => @this.Value >= 1 && @this.Value <= 100;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// <auto-generated/>
#nullable disable
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_Entity_HasName
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, bool>> Expression()
{
return (global::Foo.Entity @this) => !(@this.Name == null);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// <auto-generated/>
#nullable disable
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_Entity_IsOutOfRange
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, bool>> Expression()
{
return (global::Foo.Entity @this) => @this.Value == 0 || @this.Value > 100;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// <auto-generated/>
#nullable disable
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_Extensions_IsActiveAndPositive_P0_Foo_Entity
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, bool>> Expression()
{
return (global::Foo.Entity entity) => entity != null && entity.IsActive == true && entity.Value > 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_IEntityExtensions_Label
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.IEntity, string>> Expression()
{
return (global::Foo.IEntity @this) => @this.Id + ": " + @this.Name;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_IEntityExtensions_Label
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.IEntity, string>> Expression()
{
return (global::Foo.IEntity @this) => @this.Id + ": " + @this.Name;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_EntityExtensions_GetStatus_P0_Foo_Entity
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, string>> Expression()
{
return (global::Foo.Entity @this) => @this.IsActive && @this.Value > 0 ? "Active" : "Inactive";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_EntityExtensions_GetStatus_P0_Foo_Entity
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, string>> Expression()
{
return (global::Foo.Entity @this) => @this.IsActive && @this.Value > 0 ? "Active" : "Inactive";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_EntityExtensions_IsHighValue
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, bool>> Expression()
{
return (global::Foo.Entity @this) => @this.Value > 100;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_EntityExtensions_IsHighValue
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, bool>> Expression()
{
return (global::Foo.Entity @this) => @this.Value > 100;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_EntityExtensions_GetGrade_P0_Foo_Entity
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, string>> Expression()
{
return (global::Foo.Entity @this) => @this.Score >= 90 ? "A" : @this.Score >= 80 ? "B" : @this.Score >= 70 ? "C" : "F";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
#nullable disable
using System;
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_EntityExtensions_GetGrade_P0_Foo_Entity
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, string>> Expression()
{
return (global::Foo.Entity @this) => @this.Score >= 90 ? "A" : @this.Score >= 80 ? "B" : @this.Score >= 70 ? "C" : "F";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace EntityFrameworkCore.Projectables.Generated
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Item, global::ItemData>> Expression()
{
return (global::Item item) => item.GetType() == typeof(GroupItem) ? new global::GroupData(((GroupItem)item).Id, ((GroupItem)item).Name, ((GroupItem)item).Description) : item.GetType() == typeof(DocumentItem) ? new global::DocumentData(((DocumentItem)item).Id, ((DocumentItem)item).Name, ((DocumentItem)item).Priority) : null !;
return (global::Item item) => item is GroupItem ? new global::GroupData(((GroupItem)item).Id, ((GroupItem)item).Name, ((GroupItem)item).Description) : item is DocumentItem ? new global::DocumentData(((DocumentItem)item).Id, ((DocumentItem)item).Name, ((DocumentItem)item).Priority) : null !;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// <auto-generated/>
#nullable disable
using EntityFrameworkCore.Projectables;
using Foo;

namespace EntityFrameworkCore.Projectables.Generated
{
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
static class Foo_Entity_GetGrade
{
static global::System.Linq.Expressions.Expression<global::System.Func<global::Foo.Entity, string>> Expression()
{
return (global::Foo.Entity @this) => @this.Score >= 90 ? "A" : @this.Score >= 80 ? "B" : @this.Score >= 70 ? "C" : "F";
}
}
}
Loading