Skip to content

Commit c339415

Browse files
committed
2.22.0 Initial
1 parent 108f3c6 commit c339415

File tree

4 files changed

+136
-121
lines changed

4 files changed

+136
-121
lines changed

NpgsqlRest/Auth/AuthHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static async Task HandleLoginAsync(
6464
}
6565
else
6666
{
67-
logger?.WrongStatusType(routine.Type, routine.Schema, routine.Name);
67+
logger?.WrongStatusType(string.Concat(routine.Type, " ", routine.Schema, ".", routine.Name));
6868
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
6969
await context.Response.CompleteAsync();
7070
return;

NpgsqlRest/Defaults/DefaultCommentParser.cs

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Text.RegularExpressions;
22
using Microsoft.Extensions.Primitives;
3+
using Microsoft.Net.Http.Headers;
34

45
namespace NpgsqlRest.Defaults;
56

@@ -173,6 +174,11 @@ internal static class DefaultCommentParser
173174
}
174175
else
175176
{
177+
178+
var routineDescription = string.Concat(routine.Type, " ", routine.Schema, ".", routine.Name);
179+
var urlDescription = string.Concat(routineEndpoint.Method.ToString(), " ", routineEndpoint.Url);
180+
var description = string.Concat(routineDescription, " mapped to ", urlDescription);
181+
176182
string[] lines = comment.Split(newlineSeparator, StringSplitOptions.RemoveEmptyEntries);
177183
routineEndpoint.CommentWordLines = new string[lines.Length][];
178184
bool hasHttpTag = false;
@@ -267,15 +273,15 @@ internal static class DefaultCommentParser
267273
}
268274
else
269275
{
270-
logger?.InvalidHttpMethodComment(words[1], routine.Schema, routine.Name, routineEndpoint.Method);
276+
logger?.InvalidHttpMethodComment(words[1], description, routineEndpoint.Method);
271277
}
272278
}
273279
if (len == 3)
274280
{
275281
string urlPathSegment = words[2];
276282
if (!Uri.TryCreate(urlPathSegment, UriKind.Relative, out Uri? uri))
277283
{
278-
logger?.InvalidUrlPathSegmentComment(urlPathSegment, routine.Schema, routine.Name, routineEndpoint.Url);
284+
logger?.InvalidUrlPathSegmentComment(urlPathSegment, description, routineEndpoint.Url);
279285
}
280286
else
281287
{
@@ -290,8 +296,10 @@ internal static class DefaultCommentParser
290296
{
291297
if (options.LogAnnotationSetInfo)
292298
{
293-
logger?.CommentSetHttp(routine.Type, routine.Schema, routine.Name, routineEndpoint.Method, routineEndpoint.Url);
299+
logger?.CommentSetHttp(description, routineEndpoint.Method, routineEndpoint.Url);
294300
}
301+
urlDescription = string.Concat(routineEndpoint.Method.ToString(), " ", routineEndpoint.Url);
302+
description = string.Concat(routineDescription, " mapped to ", urlDescription);
295303
}
296304
}
297305

@@ -313,14 +321,14 @@ internal static class DefaultCommentParser
313321
}
314322
else
315323
{
316-
logger?.InvalidParameterTypeComment(words[1], routine.Schema, routine.Name, routineEndpoint.RequestParamType);
324+
logger?.InvalidParameterTypeComment(words[1], description, routineEndpoint.RequestParamType);
317325
}
318326

319327
if (originalParamType != routineEndpoint.RequestParamType)
320328
{
321329
if (options.LogAnnotationSetInfo)
322330
{
323-
logger?.CommentSetParameterType(routine.Type, routine.Schema, routine.Name, routineEndpoint.RequestParamType);
331+
logger?.CommentSetParameterType(description, routineEndpoint.RequestParamType);
324332
}
325333
}
326334
}
@@ -337,13 +345,13 @@ internal static class DefaultCommentParser
337345
routineEndpoint.AuthorizeRoles = new(words[1..]);
338346
if (options.LogAnnotationSetInfo)
339347
{
340-
logger?.CommentSetAuthRoles(routine.Type, routine.Schema, routine.Name, routineEndpoint.AuthorizeRoles);
348+
logger?.CommentSetAuthRoles(description, routineEndpoint.AuthorizeRoles);
341349
}
342350
} else
343351
{
344352
if (options.LogAnnotationSetInfo)
345353
{
346-
logger?.CommentSetAuth(routine.Type, routine.Schema, routine.Name);
354+
logger?.CommentSetAuth(description);
347355
}
348356
}
349357
}
@@ -358,7 +366,7 @@ internal static class DefaultCommentParser
358366
routineEndpoint.RequiresAuthorization = false;
359367
if (options.LogAnnotationSetInfo)
360368
{
361-
logger?.CommentSetAnon(routine.Type, routine.Schema, routine.Name);
369+
logger?.CommentSetAnon(description);
362370
}
363371
}
364372

@@ -374,14 +382,14 @@ internal static class DefaultCommentParser
374382
{
375383
if (options.LogAnnotationSetInfo)
376384
{
377-
logger?.CommentSetTimeout(routine.Type, routine.Schema, routine.Name, words[1]);
385+
logger?.CommentSetTimeout(description, words[1]);
378386
}
379387
}
380388
routineEndpoint.CommandTimeout = parsedTimeout;
381389
}
382390
else
383391
{
384-
logger?.InvalidTimeoutComment(words[1], routine.Schema, routine.Name, routineEndpoint.CommandTimeout);
392+
logger?.InvalidTimeoutComment(words[1], description, routineEndpoint.CommandTimeout);
385393
}
386394
}
387395

@@ -407,13 +415,13 @@ internal static class DefaultCommentParser
407415
}
408416
else
409417
{
410-
logger?.InvalidRequestHeadersModeComment(words[1], routine.Schema, routine.Name, routineEndpoint.RequestHeadersMode);
418+
logger?.InvalidRequestHeadersModeComment(words[1], description, routineEndpoint.RequestHeadersMode);
411419
}
412420
if (routineEndpoint.RequestHeadersMode != options.RequestHeadersMode)
413421
{
414422
if (options.LogAnnotationSetInfo)
415423
{
416-
logger?.CommentSetRequestHeadersMode(routine.Type, routine.Schema, routine.Name, words[1]);
424+
logger?.CommentSetRequestHeadersMode(description, words[1]);
417425
}
418426
}
419427
}
@@ -432,7 +440,7 @@ internal static class DefaultCommentParser
432440
{
433441
if (options.LogAnnotationSetInfo)
434442
{
435-
logger?.CommentSetRequestHeadersParamName(routine.Type, routine.Schema, routine.Name, words[1]);
443+
logger?.CommentSetRequestHeadersParamName(description, words[1]);
436444
}
437445
}
438446
routineEndpoint.RequestHeadersParameterName = words[1];
@@ -453,7 +461,7 @@ internal static class DefaultCommentParser
453461
{
454462
if (options.LogAnnotationSetInfo)
455463
{
456-
logger?.CommentSetBodyParamName(routine.Type, routine.Schema, routine.Name, words[1]);
464+
logger?.CommentSetBodyParamName(description, words[1]);
457465
}
458466
}
459467
routineEndpoint.BodyParameterName = words[1];
@@ -479,13 +487,13 @@ internal static class DefaultCommentParser
479487
}
480488
else
481489
{
482-
logger?.InvalidResponseNullHandlingModeComment(words[1], routine.Schema, routine.Name, routineEndpoint.TextResponseNullHandling);
490+
logger?.InvalidResponseNullHandlingModeComment(words[1], description, routineEndpoint.TextResponseNullHandling);
483491
}
484492
if (routineEndpoint.TextResponseNullHandling != options.TextResponseNullHandling)
485493
{
486494
if (options.LogAnnotationSetInfo)
487495
{
488-
logger?.CommentSetTextResponseNullHandling(routine.Type, routine.Schema, routine.Name, words[1]);
496+
logger?.CommentSetTextResponseNullHandling(description, words[1]);
489497
}
490498
}
491499
}
@@ -509,13 +517,13 @@ internal static class DefaultCommentParser
509517
}
510518
else
511519
{
512-
logger?.InvalidQueryStringNullHandlingComment(words[1], routine.Schema, routine.Name, routineEndpoint.QueryStringNullHandling);
520+
logger?.InvalidQueryStringNullHandlingComment(words[1], description, routineEndpoint.QueryStringNullHandling);
513521
}
514522
if (routineEndpoint.TextResponseNullHandling != options.TextResponseNullHandling)
515523
{
516524
if (options.LogAnnotationSetInfo)
517525
{
518-
logger?.CommentSetQueryStringNullHandling(routine.Type, routine.Schema, routine.Name, routineEndpoint.QueryStringNullHandling);
526+
logger?.CommentSetQueryStringNullHandling(description, routineEndpoint.QueryStringNullHandling);
519527
}
520528
}
521529
}
@@ -527,7 +535,7 @@ internal static class DefaultCommentParser
527535
routineEndpoint.Login = true;
528536
if (options.LogAnnotationSetInfo)
529537
{
530-
logger?.CommentSetLogin(routine.Type, routine.Schema, routine.Name);
538+
logger?.CommentSetLogin(description);
531539
}
532540
}
533541

@@ -538,7 +546,7 @@ internal static class DefaultCommentParser
538546
routineEndpoint.Logout = true;
539547
if (options.LogAnnotationSetInfo)
540548
{
541-
logger?.CommentSetLogout(routine.Type, routine.Schema, routine.Name);
549+
logger?.CommentSetLogout(description);
542550
}
543551
}
544552

@@ -554,37 +562,37 @@ internal static class DefaultCommentParser
554562
{
555563
if (options.LogAnnotationSetInfo)
556564
{
557-
logger?.CommentBufferRows(routine.Type, routine.Schema, routine.Name, words[1]);
565+
logger?.CommentBufferRows(description, words[1]);
558566
}
559567
}
560568
routineEndpoint.BufferRows = parsedBuffer;
561569
}
562570
else
563571
{
564-
logger?.InvalidBufferRows(words[1], routine.Schema, routine.Name, options.BufferRows);
572+
logger?.InvalidBufferRows(words[1], description, options.BufferRows);
565573
}
566574
}
567575

568576
// raw
569577
else if (haveTag is true && StrEquals(words[0], RawKey))
570578
{
571-
logger?.CommentSetRawMode(routine.Type, routine.Schema, routine.Name);
579+
logger?.CommentSetRawMode(description);
572580
routineEndpoint.Raw = true;
573581
}
574582

575583
// separator [ value ]
576584
else if (haveTag is true && line.StartsWith(string.Concat(SeparatorKey, " ")))
577585
{
578586
var sep = line[(words[0].Length + 1)..];
579-
logger?.CommentSetRawValueSeparator(routine.Type, routine.Schema, routine.Name, sep);
587+
logger?.CommentSetRawValueSeparator(description, sep);
580588
routineEndpoint.RawValueSeparator = Regex.Unescape(sep);
581589
}
582590

583591
// newline [ value ]
584592
else if (haveTag is true && len >= 2 && line.StartsWith(string.Concat(NewLineKey, " ")))
585593
{
586594
var nl = line[(words[0].Length + 1)..];
587-
logger?.CommentSetRawNewLineSeparator(routine.Type, routine.Schema, routine.Name, nl);
595+
logger?.CommentSetRawNewLineSeparator(description, nl);
588596
routineEndpoint.RawNewLineSeparator = Regex.Unescape(nl);
589597
}
590598

@@ -596,7 +604,7 @@ internal static class DefaultCommentParser
596604
routineEndpoint.RawColumnNames = true;
597605
if (options.LogAnnotationSetInfo)
598606
{
599-
logger?.CommentRawSetColumnNames(routine.Type, routine.Schema, routine.Name);
607+
logger?.CommentRawSetColumnNames(description);
600608
}
601609
}
602610

@@ -608,12 +616,12 @@ internal static class DefaultCommentParser
608616
{
609617
if (!(routine.ReturnsSet == false && routine.ColumnCount == 1 && routine.ReturnsRecordType is false))
610618
{
611-
logger?.CommentInvalidParseResponse(routine.Type, routine.Schema, routine.Name);
619+
logger?.CommentInvalidParseResponse(description);
612620
}
613621
routineEndpoint.ParseResponse = true;
614622
if (options.LogAnnotationSetInfo)
615623
{
616-
logger?.CommentParseResponse(routine.Type, routine.Schema, routine.Name);
624+
logger?.CommentParseResponse(description);
617625
}
618626
}
619627

@@ -623,7 +631,7 @@ internal static class DefaultCommentParser
623631
{
624632
if (!(routine.ReturnsSet == false && routine.ColumnCount == 1 && routine.ReturnsRecordType is false))
625633
{
626-
logger?.CommentInvalidCache(routine.Type, routine.Schema, routine.Name);
634+
logger?.CommentInvalidCache(description);
627635
}
628636
routineEndpoint.Cached = true;
629637
if (len > 1)
@@ -635,7 +643,7 @@ internal static class DefaultCommentParser
635643
var name = names[j];
636644
if (!routine.OriginalParamsHash.Contains(name) && !routine.ParamsHash.Contains(name))
637645
{
638-
logger?.CommentInvalidCacheParam(routine.Type, routine.Schema, routine.Name, name);
646+
logger?.CommentInvalidCacheParam(description, name);
639647
} else
640648
{
641649
result.Add(name);
@@ -646,7 +654,7 @@ internal static class DefaultCommentParser
646654

647655
if (options.LogAnnotationSetInfo)
648656
{
649-
logger?.CommentCached(routine.Type, routine.Schema, routine.Name, routineEndpoint.CachedParams ?? []);
657+
logger?.CommentCached(description, routineEndpoint.CachedParams ?? []);
650658
}
651659
}
652660

@@ -663,12 +671,12 @@ internal static class DefaultCommentParser
663671
routineEndpoint.CacheExpiresIn = value.Value;
664672
if (options.LogAnnotationSetInfo)
665673
{
666-
logger?.CommentCacheExpiresIn(routine.Type, routine.Schema, routine.Name, value.Value);
674+
logger?.CommentCacheExpiresIn(description, value.Value);
667675
}
668676
}
669677
else
670678
{
671-
logger?.InvalidCacheExpiresIn(routine.Type, routine.Schema, routine.Name, string.Join(Consts.Space, words[1..]));
679+
logger?.InvalidCacheExpiresIn(description, string.Join(Consts.Space, words[1..]));
672680
}
673681
}
674682

@@ -683,17 +691,17 @@ internal static class DefaultCommentParser
683691
{
684692
if (options.ConnectionStrings is null || options.ConnectionStrings.ContainsKey(name) is false)
685693
{
686-
logger?.CommentInvalidConnectionName(routine.Type, routine.Schema, routine.Name, name);
694+
logger?.CommentInvalidConnectionName(description, name);
687695
}
688696
routineEndpoint.ConnectionName = name;
689697
if (options.LogAnnotationSetInfo)
690698
{
691-
logger?.CommentConnectionName(routine.Type, routine.Schema, routine.Name, name);
699+
logger?.CommentConnectionName(description, name);
692700
}
693701
}
694702
else
695703
{
696-
logger?.CommentEmptyConnectionName(routine.Type, routine.Schema, routine.Name);
704+
logger?.CommentEmptyConnectionName(description);
697705
}
698706
}
699707

@@ -716,7 +724,7 @@ internal static class DefaultCommentParser
716724
{
717725
if (options.LogAnnotationSetInfo)
718726
{
719-
logger?.CommentSetContentType(routine.Type, routine.Schema, routine.Name, headerValue);
727+
logger?.CommentSetContentType(description, headerValue);
720728
}
721729
}
722730
routineEndpoint.ResponseContentType = headerValue;
@@ -745,7 +753,7 @@ internal static class DefaultCommentParser
745753
{
746754
if (options.LogAnnotationSetInfo)
747755
{
748-
logger?.CommentSetHeader(routine.Type, routine.Schema, routine.Name, headerName, headerValue);
756+
logger?.CommentSetHeader(description, headerName, headerValue);
749757
}
750758
}
751759
}
@@ -754,6 +762,10 @@ internal static class DefaultCommentParser
754762
}
755763
if (disabled)
756764
{
765+
if (options.LogAnnotationSetInfo)
766+
{
767+
logger?.CommentDisabled(description);
768+
}
757769
return null;
758770
}
759771
if (options.CommentsMode == CommentsMode.OnlyWithHttpTag && !hasHttpTag)

NpgsqlRest/NpgsqlRest.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
<GenerateDocumentationFile>true</GenerateDocumentationFile>
3030
<PackageReadmeFile>README.MD</PackageReadmeFile>
3131
<DocumentationFile>bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile>
32-
<Version>2.21.0</Version>
33-
<AssemblyVersion>2.21.0</AssemblyVersion>
34-
<FileVersion>2.21.0</FileVersion>
35-
<PackageVersion>2.21.0</PackageVersion>
32+
<Version>2.22.0</Version>
33+
<AssemblyVersion>2.22.0</AssemblyVersion>
34+
<FileVersion>2.22.0</FileVersion>
35+
<PackageVersion>2.22.0</PackageVersion>
3636
</PropertyGroup>
3737

3838
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

0 commit comments

Comments
 (0)