Skip to content

Commit 4dc9cc3

Browse files
committed
WIP
1 parent a4aa181 commit 4dc9cc3

4 files changed

Lines changed: 37 additions & 47 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace EasySourceGenerators.GeneratorTests;
2+
3+
public class SimpleMethodWithParameterTests
4+
{
5+
[Test]
6+
public void SimpleMethodWithParameterTests_Test()
7+
{
8+
string source = """
9+
using EasySourceGenerators.Abstractions;
10+
11+
namespace TestNamespace;
12+
13+
public partial class SimpleMethodWithParameterClass
14+
{
15+
public partial int SimpleMethodWithParameter(int someIntParameter);
16+
17+
[GeneratesMethod(sameClassMethodName: nameof(SimpleMethodWithParameter))]
18+
private static int SimpleMethodWithParameter_Generator(int someIntParameter)
19+
{
20+
return 5;
21+
}
22+
}
23+
""";
24+
25+
//TODO: This should not compile and throw error MSGH007
26+
}
27+
}

EasySourceGenerators.Generators/AnalyzerReleases.Unshipped.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ MSGH002 | GeneratesMethodGenerator | Error | GeneratesMethodGenerator
77
MSGH003 | GeneratesMethodGenerator | Disabled | GeneratesMethodGenerator
88
MSGH004 | GeneratesMethodGenerator | Error | GeneratesMethodGenerator
99
MSGH005 | GeneratesMethodGenerator | Error | GeneratesMethodGenerator
10-
MSGH006 | GeneratesMethodGenerator | Error | GeneratesMethodGenerator
10+
MSGH006 | GeneratesMethodGenerator | Error | GeneratesMethodGenerator
11+
MSGH007 | GeneratesMethodGenerator | Error | GeneratesMethodGeneratorDiagnostics

EasySourceGenerators.Generators/GeneratesMethodGenerator.Diagnostics.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@ internal static class GeneratesMethodGeneratorDiagnostics
5353
category: Category,
5454
defaultSeverity: DiagnosticSeverity.Error,
5555
isEnabledByDefault: true);
56+
57+
internal static readonly DiagnosticDescriptor CannotUseRuntimeParameterForCompileTimeGeneratorError = new(
58+
id: "MSGH007",
59+
title: "Cannot use runtime parameter for compile-time generator",
60+
messageFormat: "Method generators cannot have any parameters, as they will be run at compile time to generate the method output value. Use MethodTemplate if you want to emit method body instead of single value.",
61+
category: Category,
62+
defaultSeverity: DiagnosticSeverity.Error,
63+
isEnabledByDefault: true);
5664
}

EasySourceGenerators.Tests/SimpleMethodWithParameter.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)