Skip to content
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

Add ExpressionMethod Generator #2695

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion NuGet/PackLocal.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ECHO OFF
@ECHO OFF
viceroypenguin marked this conversation as resolved.
Show resolved Hide resolved

SET VERSION=%1
SET SNUPKG=%2
Expand Down
5 changes: 5 additions & 0 deletions NuGet/linq2db.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@
</metadata>

<files>
<!-- Primary reference files -->
<file src="..\Source\LinqToDB\bin\Release\**\linq2db.pdb" target="lib\" />
<file src="..\Source\LinqToDB\bin\Release\**\linq2db.xml" target="lib\" />
<file src="..\Source\LinqToDB\bin\Release\**\linq2db.dll" target="lib\" />

<!-- Generators -->
<file src="..\Source\LinqToDB.Analyzers\bin\Release\netstandard2.0\linq2db.Analyzers.dll"
target="analyzers\dotnet\cs" />
</files>
</package>
3 changes: 3 additions & 0 deletions Source/LinqToDB.Analyzers/AnalyzerReleases.Shipped.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
; Shipped analyzer releases
; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md

11 changes: 11 additions & 0 deletions Source/LinqToDB.Analyzers/AnalyzerReleases.Unshipped.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
; Unshipped analyzer release
; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md

### New Rules
Rule ID | Category | Severity | Notes
--------|----------|----------|-------
LDBGEN001 | LinqToDB.ExpressionMethodGenerator | Error | Diagnostics
LDBGEN002 | LinqToDB.ExpressionMethodGenerator | Error | Diagnostics
LDBGEN003 | LinqToDB.ExpressionMethodGenerator | Error | Diagnostics
LDBGEN004 | LinqToDB.ExpressionMethodGenerator | Warning | Diagnostics
LDBGEN005 | LinqToDB.ExpressionMethodGenerator | Warning | Diagnostics
55 changes: 55 additions & 0 deletions Source/LinqToDB.Analyzers/Diagnostics.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.CodeAnalysis;

namespace LinqToDB.Analyzers
{
internal static class Diagnostics
{
internal static readonly DiagnosticDescriptor ClassIsNotPartialError =
new DiagnosticDescriptor(
id: "LDBGEN001",
title: "Containing class is not marked 'partial'",
messageFormat: "Class '{0}' must be marked partial",
category: "LinqToDB.ExpressionMethodGenerator",
DiagnosticSeverity.Error,
isEnabledByDefault: true);

internal static readonly DiagnosticDescriptor MethodReturnsVoidError =
new DiagnosticDescriptor(
id: "LDBGEN002",
title: "Method has incorrect return type",
messageFormat: "Method '{0}' must not return void",
category: "LinqToDB.ExpressionMethodGenerator",
DiagnosticSeverity.Error,
isEnabledByDefault: true);

internal static readonly DiagnosticDescriptor MethodHasIncorrectShapeError =
new DiagnosticDescriptor(
id: "LDBGEN003",
title: "Method has too many statements",
messageFormat: "Method '{0}' must consist of a single return statement",
category: "LinqToDB.ExpressionMethodGenerator",
DiagnosticSeverity.Error,
isEnabledByDefault: true);

internal static readonly DiagnosticDescriptor PropertyDoesNotHaveGetWarning =
new DiagnosticDescriptor(
id: "LDBGEN004",
title: "Property does not have a get accessor",
messageFormat: "GenerateExpressionMethod applied to property '{0}', but it does not have a get accessor. No expression method will be generated for this property.",
category: "LinqToDB.ExpressionMethodGenerator",
DiagnosticSeverity.Warning,
isEnabledByDefault: true);

internal static readonly DiagnosticDescriptor MethodNameIsInvalidError =
new DiagnosticDescriptor(
id: "LDBGEN005",
title: "GenerateExpressionMethod Argument 'MethodName' is invalid",
messageFormat: "The MethodName argument for the GenerateExpressionMethod attribute must be a simple string",
category: "LinqToDB.ExpressionMethodGenerator",
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
}
}
Loading