File tree Expand file tree Collapse file tree 3 files changed +98
-4
lines changed
M31.FluentApi.Generator/SourceGenerators Expand file tree Collapse file tree 3 files changed +98
-4
lines changed Original file line number Diff line number Diff line change 1+ using System . Text . RegularExpressions ;
12using M31 . FluentApi . Generator . CodeBuilding ;
23using M31 . FluentApi . Generator . CodeGeneration . CodeBoardElements ;
34using M31 . FluentApi . Generator . CodeGeneration . CodeBoardElements . FluentApiComments ;
@@ -199,6 +200,7 @@ private static ParameterKinds GetParameterKinds(IParameterSymbol parameterSymbol
199200 return parameterKinds ;
200201 }
201202
203+ private static readonly Regex fluentApiCommentStart = new Regex ( @"^\s*////(?!/)" , RegexOptions . Compiled ) ;
202204 private static Comments GetFluentSymbolComments ( ISymbol symbol )
203205 {
204206 SyntaxReference ? syntaxRef = symbol . DeclaringSyntaxReferences . FirstOrDefault ( ) ;
@@ -220,12 +222,10 @@ private static Comments GetFluentSymbolComments(ISymbol symbol)
220222 }
221223
222224 string str = syntaxTrivia . ToString ( ) ;
223- if ( ! str . Trim ( ) . StartsWith ( "////" ) ) // todo: regex
225+ if ( fluentApiCommentStart . IsMatch ( str ) )
224226 {
225- continue ;
227+ commentLines . Add ( str . TrimStart ( '/' , ' ' ) ) ;
226228 }
227-
228- commentLines . Add ( str . TrimStart ( '/' , ' ' ) ) ;
229229 }
230230
231231 string comments = string . Join ( Environment . NewLine , commentLines ) ;
Original file line number Diff line number Diff line change 1+ // <auto-generated/>
2+ // This code was generated by the library M31.FluentAPI.
3+ // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
4+
5+ #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
6+ #nullable enable
7+
8+ namespace M31 . FluentApi . Tests . CodeGeneration . TestClasses . Abstract . FluentApiComments . WronglyCommentedClass ;
9+
10+ public class CreateStudent :
11+ CreateStudent . ICreateStudent ,
12+ CreateStudent . IWithName
13+ {
14+ private readonly Student student ;
15+
16+ private CreateStudent ( )
17+ {
18+ student = new Student ( ) ;
19+ }
20+
21+ public static ICreateStudent InitialStep ( )
22+ {
23+ return new CreateStudent ( ) ;
24+ }
25+
26+ public static Student WithName ( string name )
27+ {
28+ CreateStudent createStudent = new CreateStudent ( ) ;
29+ createStudent . student . Name = name ;
30+ return createStudent . student ;
31+ }
32+
33+ Student IWithName . WithName ( string name )
34+ {
35+ student . Name = name ;
36+ return student ;
37+ }
38+
39+ public interface ICreateStudent : IWithName
40+ {
41+ }
42+
43+ public interface IWithName
44+ {
45+ Student WithName ( string name ) ;
46+ }
47+ }
Original file line number Diff line number Diff line change 1+ // <auto-generated/>
2+ // This code was generated by the library M31.FluentAPI.
3+ // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
4+
5+ #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
6+ #nullable enable
7+
8+ namespace M31 . FluentApi . Tests . CodeGeneration . TestClasses . Abstract . FluentApiComments . WronglyCommentedClass2 ;
9+
10+ public class CreateStudent :
11+ CreateStudent . ICreateStudent ,
12+ CreateStudent . IWithName
13+ {
14+ private readonly Student student ;
15+
16+ private CreateStudent ( )
17+ {
18+ student = new Student ( ) ;
19+ }
20+
21+ public static ICreateStudent InitialStep ( )
22+ {
23+ return new CreateStudent ( ) ;
24+ }
25+
26+ public static Student WithName ( string name )
27+ {
28+ CreateStudent createStudent = new CreateStudent ( ) ;
29+ createStudent . student . Name = name ;
30+ return createStudent . student ;
31+ }
32+
33+ Student IWithName . WithName ( string name )
34+ {
35+ student . Name = name ;
36+ return student ;
37+ }
38+
39+ public interface ICreateStudent : IWithName
40+ {
41+ }
42+
43+ public interface IWithName
44+ {
45+ Student WithName ( string name ) ;
46+ }
47+ }
You can’t perform that action at this time.
0 commit comments