Skip to content

Commit 434b3cf

Browse files
mkarlehario90markwallace-microsoft
authored
.Net: Update missing documentation (microsoft#2538)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> CA1591 was suppressed, so many files were missing documentation. This removes that suppression and adds comments. I used https://github.com/mkarle/sk-autodocs to automatically generate the documentation. ### Description - Unsuppressed CA1591 from top-level editorconfig but kept it suppressed for unit tests - Ran `dotnet build | Out-File -FilePath .\log.log` to get a log of missing XML documentation - Ran ` sk-autodocs --dotnet-build-log log.log` to generate documentation for the files missing documentation - Went through each file and (hopefully) corrected any mistakes. The most common problems were that it would change the namespace to braces or remove the empty line at the end. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 --------- Co-authored-by: Lisa Harrylock <[email protected]> Co-authored-by: Mark Wallace <[email protected]>
1 parent 16d3004 commit 434b3cf

File tree

79 files changed

+819
-90
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+819
-90
lines changed

.editorconfig

-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ dotnet_diagnostic.CA1032.severity = none # We're using RCS1194 which seems to co
163163
dotnet_diagnostic.CA1034.severity = none # Do not nest type. Alternatively, change its accessibility so that it is not externally visible
164164
dotnet_diagnostic.CA1062.severity = none # Disable null check, C# already does it for us
165165
dotnet_diagnostic.CA1303.severity = none # Do not pass literals as localized parameters
166-
dotnet_diagnostic.CS1591.severity = none # Missing XML comment for publicly visible type or member
167166
dotnet_diagnostic.CA1805.severity = none # Member is explicitly initialized to its default value
168167
dotnet_diagnostic.CA1822.severity = none # Member does not access instance data and can be marked as static
169168
dotnet_diagnostic.CA1848.severity = none # For improved performance, use the LoggerMessage delegates

dotnet/samples/ApplicationInsightsExample/Program.cs

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public sealed class Program
3535
/// </remarks>
3636
private static LogLevel LogLevel = LogLevel.Information;
3737

38+
/// <summary>
39+
/// The main entry point for the application.
40+
/// </summary>
41+
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
3842
public static async Task Main()
3943
{
4044
var serviceProvider = GetServiceProvider();

dotnet/samples/KernelSyntaxExamples/KernelSyntaxExamples.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<OutputType>Exe</OutputType>
1010
<IsPackable>false</IsPackable>
1111
<!-- Suppress: "Declare types in namespaces", "Require ConfigureAwait" -->
12-
<NoWarn>CA1050;CA1707;CA2007;VSTHRD111</NoWarn>
12+
<NoWarn>CA1050;CA1707;CA2007;VSTHRD111;CS1591</NoWarn>
1313
</PropertyGroup>
1414
<ItemGroup>
1515
<None Remove="appsettings.json" />
@@ -64,4 +64,5 @@
6464
<EmbeddedResource Include="Resources\30-system-prompt.txt" />
6565
<EmbeddedResource Include="Resources\30-user-context.txt" />
6666
</ItemGroup>
67+
6768
</Project>

dotnet/samples/NCalcSkills/LanguageCalculatorSkill.cs

+10
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ [End of Examples]
6161
Question: {{ $input }}
6262
";
6363

64+
/// <summary>
65+
/// Initializes a new instance of the <see cref="LanguageCalculatorSkill"/> class.
66+
/// </summary>
67+
/// <param name="kernel">The kernel to be used for creating the semantic function.</param>
6468
public LanguageCalculatorSkill(IKernel kernel)
6569
{
6670
this._mathTranslator = kernel.CreateSemanticFunction(
@@ -73,6 +77,12 @@ public LanguageCalculatorSkill(IKernel kernel)
7377
topP: 1);
7478
}
7579

80+
/// <summary>
81+
/// Calculates the result of a non-trivial math expression.
82+
/// </summary>
83+
/// <param name="input">A valid mathematical expression that could be executed by a calculator capable of more advanced math functions like sine/cosine/floor.</param>
84+
/// <param name="context">The context for the skill execution.</param>
85+
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
7686
[SKFunction, SKName("Calculator"), Description("Useful for getting the result of a non-trivial math expression.")]
7787
public async Task<string> CalculateAsync(
7888
[Description("A valid mathematical expression that could be executed by a calculator capable of more advanced math functions like sin/cosine/floor.")]

dotnet/samples/NCalcSkills/SimpleCalculatorSkill.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66
namespace NCalcSkills;
77

88
/// <summary>
9-
/// Simple calculator skill
9+
/// Simple calculator skill that evaluates a mathematical expression.
1010
/// </summary>
1111
public class SimpleCalculatorSkill
1212
{
1313
private readonly ISKFunction _mathTranslator;
1414

1515
private static readonly string[] s_stopSequences = new[] { "Problem:", "Solution:" };
1616

17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="SimpleCalculatorSkill"/> class.
19+
/// </summary>
20+
/// <param name="kernel">The kernel used to create the semantic function.</param>
1721
public SimpleCalculatorSkill(IKernel kernel)
1822
{
1923
this._mathTranslator = kernel.CreateSemanticFunction(

dotnet/src/Connectors/Connectors.AI.HuggingFace/HuggingFaceModelResultExtension.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77

88
namespace Microsoft.SemanticKernel;
99

10+
/// <summary>
11+
/// Provides an extension method for working with Hugging Face model results.
12+
/// </summary>
1013
public static class HuggingFaceModelResultExtension
1114
{
1215
/// <summary>
13-
/// Retrieves a typed <see cref="TextCompletionResponse"/> hugging face result from PromptResult/>.
16+
/// Retrieves a typed <see cref="TextCompletionResponse"/> hugging face result from <see cref="ModelResult"/>.
1417
/// </summary>
15-
/// <param name="resultBase">Current context</param>
16-
/// <returns>Hugging face result <see cref="TextCompletionResponse"/></returns>
18+
/// <param name="resultBase">The <see cref="ModelResult"/> instance to retrieve the hugging face result from.</param>
19+
/// <returns>A <see cref="TextCompletionResponse"/> instance containing the hugging face result.</returns>
1720
public static TextCompletionResponse GetHuggingFaceResult(this ModelResult resultBase)
1821
{
1922
return resultBase.GetResult<TextCompletionResponse>();

dotnet/src/Connectors/Connectors.AI.HuggingFace/TextEmbedding/TextEmbeddingResponse.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@
88
namespace Microsoft.SemanticKernel.Connectors.AI.HuggingFace.TextEmbedding;
99

1010
/// <summary>
11-
/// HTTP Schema for embedding response.
11+
/// Represents the response from the Hugging Face text embedding API.
1212
/// </summary>
1313
public sealed class TextEmbeddingResponse
1414
{
1515
/// <summary>
16-
/// Model containing embedding.
16+
/// Represents the embedding vector for a given text.
1717
/// </summary>
1818
public sealed class EmbeddingVector
1919
{
20+
/// <summary>
21+
/// The embedding vector as a ReadOnlyMemory of float values.
22+
/// </summary>
2023
[JsonPropertyName("embedding")]
2124
[JsonConverter(typeof(ReadOnlyMemoryConverter))]
2225
public ReadOnlyMemory<float> Embedding { get; set; }

dotnet/src/Connectors/Connectors.AI.Oobabooga/TextCompletion/OobaboogaTextCompletion.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ namespace Microsoft.SemanticKernel.Connectors.AI.Oobabooga.TextCompletion;
2424
/// </summary>
2525
public sealed class OobaboogaTextCompletion : ITextCompletion
2626
{
27+
/// <summary>
28+
/// The URI path for blocking API requests.
29+
/// </summary>
2730
public const string BlockingUriPath = "/api/v1/generate";
2831
private const string StreamingUriPath = "/api/v1/stream";
2932

@@ -41,7 +44,7 @@ public sealed class OobaboogaTextCompletion : ITextCompletion
4144
private long _lastCallTicks = long.MaxValue;
4245

4346
/// <summary>
44-
/// Controls the size of the buffer used to received websocket packets
47+
/// Controls the size of the buffer used to receive websocket packets.
4548
/// </summary>
4649
public int WebSocketBufferSize { get; set; } = 2048;
4750

dotnet/src/Connectors/Connectors.AI.Oobabooga/TextCompletion/TextCompletionStreamingResponse.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
namespace Microsoft.SemanticKernel.Connectors.AI.Oobabooga.TextCompletion;
66

77
/// <summary>
8-
/// HTTP Schema for streaming completion response. Adapted from <see href="https://github.com/oobabooga/text-generation-webui/blob/main/extensions/api/streaming_api.py"/>
8+
/// Represents the HTTP schema for streaming completion response. Adapted from <see href="https://github.com/oobabooga/text-generation-webui/blob/main/extensions/api/streaming_api.py"/>.
99
/// </summary>
1010
public sealed class TextCompletionStreamingResponse
1111
{
12+
/// <summary>
13+
/// Constant string representing the event that is fired when text is received from a websocket.
14+
/// </summary>
1215
public const string ResponseObjectTextStreamEvent = "text_stream";
16+
17+
/// <summary>
18+
/// Constant string representing the event that is fired when streaming from a websocket ends.
19+
/// </summary>
1320
public const string ResponseObjectStreamEndEvent = "stream_end";
1421

1522
/// <summary>

dotnet/src/Connectors/Connectors.AI.OpenAI/AzureSdk/AzureOpenAIClientBase.cs

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
using Microsoft.SemanticKernel.Diagnostics;
1212

1313
namespace Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk;
14-
14+
/// <summary>
15+
/// Base class for Azure OpenAI clients.
16+
/// </summary>
1517
public abstract class AzureOpenAIClientBase : ClientBase
1618
{
1719
/// <summary>
@@ -20,7 +22,7 @@ public abstract class AzureOpenAIClientBase : ClientBase
2022
private protected override OpenAIClient Client { get; }
2123

2224
/// <summary>
23-
/// Creates a new Azure OpenAI client instance using API Key auth
25+
/// Initializes a new instance of the <see cref="AzureOpenAIClientBase"/> class using API Key authentication.
2426
/// </summary>
2527
/// <param name="modelId">Azure OpenAI model ID or deployment name, see https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource</param>
2628
/// <param name="endpoint">Azure OpenAI deployment URL, see https://learn.microsoft.com/azure/cognitive-services/openai/quickstart</param>
@@ -50,7 +52,7 @@ private protected AzureOpenAIClientBase(
5052
}
5153

5254
/// <summary>
53-
/// Creates a new Azure OpenAI client instance supporting AAD auth
55+
/// Initializes a new instance of the <see cref="AzureOpenAIClientBase"/> class supporting AAD authentication.
5456
/// </summary>
5557
/// <param name="modelId">Azure OpenAI model ID or deployment name, see https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource</param>
5658
/// <param name="endpoint">Azure OpenAI deployment URL, see https://learn.microsoft.com/azure/cognitive-services/openai/quickstart</param>
@@ -79,8 +81,8 @@ private protected AzureOpenAIClientBase(
7981
}
8082

8183
/// <summary>
82-
/// Creates a new Azure OpenAI client instance using the specified OpenAIClient
83-
/// Note: instances created this way might not have the default diagnostics settings,
84+
/// Initializes a new instance of the <see cref="AzureOpenAIClientBase"/> class using the specified OpenAIClient.
85+
/// Note: instances created this way might not have the default diagnostics settings,
8486
/// it's up to the caller to configure the client.
8587
/// </summary>
8688
/// <param name="modelId">Azure OpenAI model ID or deployment name, see https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource</param>
@@ -101,6 +103,7 @@ private protected AzureOpenAIClientBase(
101103
/// <summary>
102104
/// Options used by the Azure OpenAI client, e.g. User Agent.
103105
/// </summary>
106+
/// <returns>An instance of <see cref="OpenAIClientOptions"/>.</returns>
104107
private static OpenAIClientOptions GetClientOptions()
105108
{
106109
return new OpenAIClientOptions

dotnet/src/Connectors/Connectors.AI.OpenAI/AzureSdk/ClientBase.cs

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ namespace Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk;
2121

2222
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
2323

24+
/// <summary>
25+
/// Base class for AI clients that provides common functionality for interacting with OpenAI services.
26+
/// </summary>
2427
public abstract class ClientBase
2528
{
2629
private const int MaxResultsPerPrompt = 128;

dotnet/src/Connectors/Connectors.AI.OpenAI/AzureSdk/OpenAIClientBase.cs

+9-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
namespace Microsoft.SemanticKernel.Connectors.AI.OpenAI.AzureSdk;
1212

13+
/// <summary>
14+
/// Base class for OpenAI clients, providing common functionality and properties.
15+
/// </summary>
1316
public abstract class OpenAIClientBase : ClientBase
1417
{
1518
/// <summary>
@@ -18,11 +21,11 @@ public abstract class OpenAIClientBase : ClientBase
1821
private protected override OpenAIClient Client { get; }
1922

2023
/// <summary>
21-
/// Create an instance of the OpenAI connector
24+
/// Initializes a new instance of the <see cref="OpenAIClientBase"/> class.
2225
/// </summary>
23-
/// <param name="modelId">Model name</param>
24-
/// <param name="apiKey">OpenAI API Key</param>
25-
/// <param name="organization">OpenAI Organization Id (usually optional)</param>
26+
/// <param name="modelId">Model name.</param>
27+
/// <param name="apiKey">OpenAI API Key.</param>
28+
/// <param name="organization">OpenAI Organization Id (usually optional).</param>
2629
/// <param name="httpClient">Custom <see cref="HttpClient"/> for HTTP requests.</param>
2730
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> to use for logging. If null, no logging will be performed.</param>
2831
private protected OpenAIClientBase(
@@ -52,7 +55,7 @@ private protected OpenAIClientBase(
5255
}
5356

5457
/// <summary>
55-
/// Creates a new OpenAI client instance using the specified OpenAIClient
58+
/// Initializes a new instance of the <see cref="OpenAIClientBase"/> class using the specified OpenAIClient.
5659
/// Note: instances created this way might not have the default diagnostics settings,
5760
/// it's up to the caller to configure the client.
5861
/// </summary>
@@ -83,6 +86,7 @@ private protected void LogActionDetails([CallerMemberName] string? callerMemberN
8386
/// <summary>
8487
/// Options used by the OpenAI client, e.g. User Agent.
8588
/// </summary>
89+
/// <returns>An instance of <see cref="OpenAIClientOptions"/> with the configured options.</returns>
8690
private static OpenAIClientOptions GetClientOptions()
8791
{
8892
return new OpenAIClientOptions

dotnet/src/Connectors/Connectors.AI.OpenAI/ImageGeneration/OpenAIImageGeneration.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
using Microsoft.SemanticKernel.Text;
1313

1414
namespace Microsoft.SemanticKernel.Connectors.AI.OpenAI.ImageGeneration;
15-
15+
/// <summary>
16+
/// A class for generating images using OpenAI's API.
17+
/// </summary>
1618
public class OpenAIImageGeneration : OpenAIClientBase, IImageGeneration
1719
{
1820
/// <summary>
@@ -31,7 +33,7 @@ public class OpenAIImageGeneration : OpenAIClientBase, IImageGeneration
3133
private readonly string _authorizationHeaderValue;
3234

3335
/// <summary>
34-
/// Create a new instance of OpenAI image generation service
36+
/// Initializes a new instance of the <see cref="OpenAIImageGeneration"/> class.
3537
/// </summary>
3638
/// <param name="apiKey">OpenAI API key, see https://platform.openai.com/account/api-keys</param>
3739
/// <param name="organization">OpenAI organization id. This is usually optional unless your account belongs to multiple organizations.</param>

dotnet/src/Connectors/Connectors.AI.OpenAI/OpenAIModelResultExtensions.cs

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Microsoft.SemanticKernel;
1010

11+
/// <summary>
12+
/// Provides extension methods for working with OpenAI model results.
13+
/// </summary>
1114
public static class OpenAIModelResultExtension
1215
{
1316
/// <summary>

dotnet/src/Connectors/Connectors.AI.OpenAI/Tokenizers/GPT3Tokenizer.cs

+15
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,31 @@ static unsafe int EncodingUtf8GetBytes(ReadOnlySpan<char> chars, Span<byte> byte
164164
}
165165
}
166166

167+
/// <summary>
168+
/// Tokenizes the text in the provided StringBuilder.
169+
/// </summary>
170+
/// <param name="stringBuilder">StringBuilder containing the text to tokenize</param>
171+
/// <returns>List of token IDs</returns>
167172
public static List<int> Encode(StringBuilder? stringBuilder) =>
168173
stringBuilder is not null
169174
? Encode(stringBuilder.ToString())
170175
: new List<int>();
171176

177+
/// <summary>
178+
/// Tokenizes the text in the provided char array.
179+
/// </summary>
180+
/// <param name="chars">Char array containing the text to tokenize</param>
181+
/// <returns>List of token IDs</returns>
172182
public static List<int> Encode(char[]? chars) =>
173183
chars is not null
174184
? Encode(new string(chars))
175185
: new List<int>();
176186

187+
/// <summary>
188+
/// Tokenizes the text in the provided IEnumerable of chars.
189+
/// </summary>
190+
/// <param name="chars">IEnumerable of chars containing the text to tokenize</param>
191+
/// <returns>List of token IDs</returns>
177192
public static List<int> Encode(IEnumerable<char>? chars) =>
178193
chars is not null
179194
? Encode(string.Concat(chars))

0 commit comments

Comments
 (0)