Skip to content

Commit

Permalink
making member vars (able to be doc'd via code refactor) better docume…
Browse files Browse the repository at this point in the history
…nted
  • Loading branch information
bc3tech committed Feb 8, 2024
1 parent b90078d commit d53c597
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion DocGpt.Roslyn/DocGptExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ internal static class DocGptExecutor
completionOptions.Messages.Add(new ChatRequestUserMessage($@"You are to take the C# code below and create a valid XML Documentation summary block for it according to .NET specifications. Use the following steps to determine what you compute for the answer:
1. If the given code is not a complete C# type or member declaration, stop computing and return nothing.
2. If you're not able to discern the purpose of the code with reasonable certainty, just return `/// <summary />`
2. If the declaration is a variable or field, your summary should attempt to discern what the variable may mean based on its name and - if assigned - its value. Don't include the ""gets or sets"" verbiage.
3. If you're not able to discern the purpose of the code with reasonable certainty, just return `/// <summary />`
```csharp
{code}
Expand Down
10 changes: 9 additions & 1 deletion DocGpt.Roslyn/DocGptRefactoringProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;

using System;
using System.Composition;
Expand All @@ -28,7 +29,14 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
SyntaxNode node = root.FindNode(textSpan);
if (!DocGptExecutor.SupportedSyntaxes.Contains(node.Kind()))
{
return;
if (node.Parent?.Parent is FieldDeclarationSyntax)
{
node = node.Parent.Parent;
}
else
{
return;
}
}

// Register a code action that will invoke the fix.
Expand Down

0 comments on commit d53c597

Please sign in to comment.