Skip to content

Commit 196d2c6

Browse files
committed
Fixed bug with TODO comments on single word
1 parent bf5d8c9 commit 196d2c6

File tree

8 files changed

+238
-210
lines changed

8 files changed

+238
-210
lines changed

CodeDocumentor.Common/Extensions/ListExtensions.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static List<string> HandleAsyncKeyword(this List<string> parts, bool excl
163163

164164
public static List<string> TryAddTodoSummary(this List<string> parts, string returnType, bool useToDoCommentsOnSummaryError)
165165
{
166-
if (returnType == "void" && (parts.Count == 1 || (parts.Count == 2 && parts.Last() == "asynchronously")))
166+
if (IsReturnVoidAndOnePart(parts, returnType) || IsOnePart(parts))
167167
{
168168
if (useToDoCommentsOnSummaryError)
169169
{
@@ -177,6 +177,15 @@ public static List<string> TryAddTodoSummary(this List<string> parts, string ret
177177
return parts;
178178
}
179179

180+
private static bool IsReturnVoidAndOnePart(List<string> parts, string returnType) {
181+
return returnType == "void" && (parts.Count == 1 || (parts.Count == 2 && parts.Last() == "asynchronously"));
182+
}
183+
184+
private static bool IsOnePart(List<string> parts)
185+
{
186+
return (parts.Count <= 1 || (parts.Count == 2 && parts.Last() == "asynchronously"));
187+
}
188+
180189
public static List<string> TryPluarizeFirstWord(this List<string> parts)
181190
{
182191
if (parts.Count > 0)

CodeDocumentor.Common/Extensions/StringExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ public static string RemovePeriod(this string text)
1010
}
1111

1212
/// <summary>
13-
/// Withs the period.
13+
/// Add period if does not exist.
1414
/// </summary>
1515
/// <param name="text"> The text. </param>
1616
/// <returns> A string. </returns>
1717
public static string WithPeriod(this string text)
1818
{
19-
if (text?.Trim().EndsWith(".") == true)
19+
if (!string.IsNullOrWhiteSpace(text) && text.Trim().EndsWith("."))
2020
{
2121
return text;
2222
}

CodeDocumentor.Common/Extensions/Translator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public static class Translator
1313
/// <returns> A string </returns>
1414
public static string ApplyUserTranslations(this string text, WordMap[] wordMaps)
1515
{
16+
if (string.IsNullOrWhiteSpace(text))
17+
{
18+
return text;
19+
}
1620
return TranslateText(text, wordMaps);
1721
}
1822

CodeDocumentor.Common/Models/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public ISettings Clone()
108108
RecordDiagnosticSeverity = RecordDiagnosticSeverity,
109109
TryToIncludeCrefsForReturnTypes = TryToIncludeCrefsForReturnTypes,
110110
UseNaturalLanguageForReturnNode = UseNaturalLanguageForReturnNode,
111-
UseToDoCommentsOnSummaryError = UseNaturalLanguageForReturnNode
111+
UseToDoCommentsOnSummaryError = UseToDoCommentsOnSummaryError
112112
};
113113
var clonedMaps = new List<WordMap>();
114114
foreach (var item in WordMaps)

CodeDocumentor/Analyzers/BaseCodeFixProvider.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Collections.Generic;
22
using System.Collections.Immutable;
3-
#if DEBUG
4-
#endif
3+
using System.Diagnostics;
54
using System.Threading.Tasks;
65
using CodeDocumentor.Common;
76
using CodeDocumentor.Common.Interfaces;
@@ -65,8 +64,8 @@ public override FixAllProvider GetFixAllProvider()
6564
protected async Task RegisterFileCodeFixesAsync(CodeFixContext context, Diagnostic diagnostic)
6665
{
6766
#if DEBUG
68-
//Debug.WriteLine("!!!DISABLING FILE CODE FIX. EITHER TESTS ARE RUNNING OR DEBUGGER IS ATTACHED!!!");
69-
//return;
67+
Debug.WriteLine("!!!DISABLING FILE CODE FIX. EITHER TESTS ARE RUNNING OR DEBUGGER IS ATTACHED!!!");
68+
return;
7069
#endif
7170
//build it up, but check for counts if anything actually needs to be shown
7271
var tempDoc = context.Document;

CodeDocumentor/Helper/CommentHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ public string CreateMethodComment(string name, TypeSyntax returnType,
190190
.TryInsertTheWord((parts) =>
191191
{
192192
//this means any name of a method that is not a return type of bool and not 2 part (+async) should insert "the" into the sentence
193-
if (!isBool &&
193+
if (parts.Count > 0 &&
194+
!isBool &&
194195
!hasReturnComment &&
195196
!Constants.EXCLUDE_THE_LIST_FOR_2PART_COMMENTS.Any(a => a.Equals(parts[0], StringComparison.InvariantCultureIgnoreCase)) &&
196197
is2partPlusAsync)

Manifests/vs2022/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="CodeDocumentor.2022.88F29096-CA4C-4F88-A260-705D8BBFCF2A" Version="3.0.0.2" Language="en-US" Publisher="Dan Turco"/>
4+
<Identity Id="CodeDocumentor.2022.88F29096-CA4C-4F88-A260-705D8BBFCF2A" Version="3.0.1.0" Language="en-US" Publisher="Dan Turco"/>
55
<DisplayName>CodeDocumentor</DisplayName>
66
<Description xml:space="preserve">An Extension to generate XML documentation automatically using IntelliSense for interface,class,enum, field, constructor, property and method.</Description>
77
<Icon>logo.png</Icon>

0 commit comments

Comments
 (0)