Skip to content

Commit

Permalink
Missing copyright, typos, code style (microsoft#847)
Browse files Browse the repository at this point in the history
Add missing copyright
Fix incorrect namespaces
Remove dead code
Fix typos
Fix indentation
Fix spacing
  • Loading branch information
dluc committed May 8, 2023
1 parent a1bdafb commit 1b01049
Show file tree
Hide file tree
Showing 25 changed files with 69 additions and 61 deletions.
2 changes: 2 additions & 0 deletions dotnet/SK-dotnet.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OK/@EntryIndexedValue">OK</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OS/@EntryIndexedValue">OS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PR/@EntryIndexedValue">PR</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QA/@EntryIndexedValue">QA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SK/@EntryIndexedValue">SK</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SKHTTP/@EntryIndexedValue">SKHTTP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SSL/@EntryIndexedValue">SSL</s:String>
Expand Down Expand Up @@ -188,6 +189,7 @@ public void It$SOMENAME$()
<s:Boolean x:Key="/Default/UserDictionary/Words/=Chunker/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ctors/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=davinci/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ENDPART/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=greaterthan/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Joinable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=keyvault/@EntryIndexedValue">True</s:Boolean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public abstract class ClientBase
}

/// <summary>
/// Creates a completion stream for the pormpt and settings.
/// Creates a completion stream for the prompt and settings.
/// </summary>
/// <param name="text">The prompt to complete.</param>
/// <param name="requestSettings">Request settings for the completion API</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ private async Task<T> ExecutePostRequestAsync<T>(string url, string requestBody,
var result = Json.Deserialize<T>(responseJson);
if (result is null)
{
throw new AIException(
AIException.ErrorCodes.InvalidResponseContent,
"Response JSON parse error");
throw new AIException(AIException.ErrorCodes.InvalidResponseContent, "Response JSON parse error");
}

return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.SemanticKernel.Connectors.Memory.Qdrant.Diagnostics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="SemanticKernelConnectorsSqliteTests" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernelConnectorsSqliteTests" PublicKey="$(StrongNamePublicKey)"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="IntegrationTests" PublicKey="$(StongNamePublicKey)" />
<InternalsVisibleTo Include="IntegrationTests" PublicKey="$(StrongNamePublicKey)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="IntegrationTests" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.Extensions.UnitTests" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="IntegrationTests" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.Extensions.UnitTests" PublicKey="$(StrongNamePublicKey)"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public Uri BuildOperationUrl(IDictionary<string, string> arguments)

//Getting metadata for the header
var headerMetadata = this.Parameters.FirstOrDefault(p => p.Location == RestApiOperationParameterLocation.Header && p.Name == headerName)
?? throw new RestApiOperationException($"No value for the '{headerName} header is found.'");
?? throw new RestApiOperationException($"No value for the '{headerName} header is found.'");

//If parameter is required it's value should always be provided.
if (headerMetadata.IsRequired)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Core" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Connectors.AI.OpenAI" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Planning.ActionPlanner" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Planning.SequentialPlanner" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Skills.OpenAPI" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Connectors.Memory.CosmosDB" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.Skills.UnitTests" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.UnitTests" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="IntegrationTests" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="$(StongNamePublicKey)"/> <!-- Moq -->
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Core" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Connectors.AI.OpenAI" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Planning.ActionPlanner" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Planning.SequentialPlanner" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Skills.OpenAPI" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Connectors.Memory.CosmosDB" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.Skills.UnitTests" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.UnitTests" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="IntegrationTests" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="$(StrongNamePublicKey)"/> <!-- Moq -->
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.

// ReSharper disable once CheckNamespace - Using NS of SKContext

namespace Microsoft.SemanticKernel.Orchestration;

/// <summary>
Expand Down
16 changes: 8 additions & 8 deletions dotnet/src/SemanticKernel/SemanticKernel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ Install this package manually only if you are selecting individual Semantic Kern
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Planning.ActionPlanner" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Planning.SequentialPlanner" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Connectors.AI.OpenAI" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Skills.OpenAPI" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.UnitTests" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.Skills.UnitTests" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.IntegrationTests" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="$(StongNamePublicKey)"/> <!-- Moq -->
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Planning.ActionPlanner" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Planning.SequentialPlanner" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Connectors.AI.OpenAI" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="Microsoft.SemanticKernel.Skills.OpenAPI" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.UnitTests" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.Skills.UnitTests" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.IntegrationTests" PublicKey="$(StrongNamePublicKey)"/>
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="$(StrongNamePublicKey)"/> <!-- Moq -->
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@ public static Models.EmailAddress ToEmailAddress(this Microsoft.Graph.EmailAddre
/// Convert a calendar event to a Microsoft Graph event.
/// </summary>
public static Graph.Event ToGraphEvent(this CalendarEvent calendarEvent)
=> new()
{
Subject = calendarEvent.Subject,
Body = new ItemBody { Content = calendarEvent.Content, ContentType = BodyType.Html },
Start = calendarEvent.Start.HasValue ? DateTimeTimeZone.FromDateTimeOffset(calendarEvent.Start.Value) : DateTimeTimeZone.FromDateTime(System.DateTime.Now),
End = calendarEvent.End.HasValue ? DateTimeTimeZone.FromDateTimeOffset(calendarEvent.End.Value) : DateTimeTimeZone.FromDateTime(System.DateTime.Now + TimeSpan.FromHours(1)),
Location = new Location { DisplayName = calendarEvent.Location },
Attendees = calendarEvent.Attendees?.Select(a => new Attendee { EmailAddress = new Microsoft.Graph.EmailAddress { Address = a } })
};
=> new()
{
Subject = calendarEvent.Subject,
Body = new ItemBody { Content = calendarEvent.Content, ContentType = BodyType.Html },
Start = calendarEvent.Start.HasValue
? DateTimeTimeZone.FromDateTimeOffset(calendarEvent.Start.Value)
: DateTimeTimeZone.FromDateTime(System.DateTime.Now),
End = calendarEvent.End.HasValue
? DateTimeTimeZone.FromDateTimeOffset(calendarEvent.End.Value)
: DateTimeTimeZone.FromDateTime(System.DateTime.Now + TimeSpan.FromHours(1)),
Location = new Location { DisplayName = calendarEvent.Location },
Attendees = calendarEvent.Attendees?.Select(a => new Attendee { EmailAddress = new Microsoft.Graph.EmailAddress { Address = a } })
};

/// <summary>
/// Convert a Microsoft Graph event to a calendar event.
Expand All @@ -69,4 +73,3 @@ public static Models.CalendarEvent ToCalendarEvent(this Event msGraphEvent)
Attendees = msGraphEvent.Attendees?.Select(a => a.EmailAddress.Address)
};
}

12 changes: 6 additions & 6 deletions dotnet/src/Skills/Skills.MsGraph/EmailSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Graph;
using Microsoft.SemanticKernel.Orchestration;
using Microsoft.SemanticKernel.SkillDefinition;
using Microsoft.SemanticKernel.Skills.MsGraph.Diagnostics;
using Microsoft.SemanticKernel.Skills.MsGraph.Models;

namespace Microsoft.SemanticKernel.Skills.MsGraph;

Expand Down Expand Up @@ -128,11 +128,11 @@ public async Task<string> GetEmailMessagesAsync(SKContext context)
}
}

IEnumerable<Models.EmailMessage> messages = await this._connector.GetMessagesAsync(
top: top,
skip: skip,
select: selectString,
context.CancellationToken)
IEnumerable<EmailMessage> messages = await this._connector.GetMessagesAsync(
top: top,
skip: skip,
select: selectString,
context.CancellationToken)
.ConfigureAwait(false);

return JsonSerializer.Serialize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Net.Http;
using System.Text.RegularExpressions;
using Microsoft.SemanticKernel.Connectors.WebApi.Rest.Model;
using Microsoft.SemanticKernel.Text;

#pragma warning disable IDE0130
// ReSharper disable once CheckNamespace
Expand Down Expand Up @@ -37,7 +36,6 @@ public static IReadOnlyList<RestApiOperationParameter> GetParameters(this RestAp
defaultValue: serverUrlOverride?.AbsoluteUri ?? operation.ServerUrl?.AbsoluteUri)
};


// Register the "payload" parameter to be advertised for Put and Post operations.
if (operation.Method == HttpMethod.Put || operation.Method == HttpMethod.Post)
{
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/Skills/Skills.OpenAPI/Skills.OpenAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="SemanticKernel.Skills.UnitTests" PublicKey="$(StongNamePublicKey)"/>
<InternalsVisibleTo Include="SemanticKernel.Skills.UnitTests" PublicKey="$(StrongNamePublicKey)"/>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/Skills/Skills.Web/Bing/BingConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public BingConnector(string apiKey, ILogger<BingConnector>? logger = null)
public async Task<IEnumerable<string>> SearchAsync(string query, int count = 1, int offset = 0, CancellationToken cancellationToken = default)
{
if (count <= 0) { throw new ArgumentOutOfRangeException(nameof(count)); }

if (count >= 50) { throw new ArgumentOutOfRangeException(nameof(count), "{nameof(count)} value must be less than 50."); }

if (offset < 0) { throw new ArgumentOutOfRangeException(nameof(offset)); }

Uri uri = new($"https://api.bing.microsoft.com/v7.0/search?q={Uri.EscapeDataString(query)}&count={count}&offset={offset}");
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/Skills/Skills.Web/Google/GoogleConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public sealed class GoogleConnector : IWebSearchEngineConnector, IDisposable
CancellationToken cancellationToken)
{
if (count <= 0) { throw new ArgumentOutOfRangeException(nameof(count)); }

if (count > 10) { throw new ArgumentOutOfRangeException(nameof(count), "{nameof(count)} value must be between 0 and 10, inclusive."); }

if (offset < 0) { throw new ArgumentOutOfRangeException(nameof(offset)); }

var search = this._search.Cse.List();
Expand Down
2 changes: 1 addition & 1 deletion samples/apps/copilot-chat-app/webapi/Skills/ChatSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Microsoft.SemanticKernel.SkillDefinition;
using SemanticKernel.Service.Config;
using SemanticKernel.Service.Model;
using SemanticKernel.Service.Skills.OpenApiSkills;
using SemanticKernel.Service.Skills.OpenApiSkills.GitHubSkill.Model;
using SemanticKernel.Service.Storage;

namespace SemanticKernel.Service.Skills;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Text.Json.Serialization;
// Copyright (c) Microsoft. All rights reserved.

namespace SemanticKernel.Service.Skills.OpenApiSkills;
using System.Text.Json.Serialization;

namespace SemanticKernel.Service.Skills.OpenApiSkills.GitHubSkill.Model;

/// <summary>
/// Represents a pull request label.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Text.Json.Serialization;
// Copyright (c) Microsoft. All rights reserved.

namespace SemanticKernel.Service.Skills.OpenApiSkills;
using System.Text.Json.Serialization;

namespace SemanticKernel.Service.Skills.OpenApiSkills.GitHubSkill.Model;

/// <summary>
/// Represents a GitHub Pull Request.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Text.Json.Serialization;
// Copyright (c) Microsoft. All rights reserved.

namespace SemanticKernel.Service.Skills.OpenApiSkills;
using System.Text.Json.Serialization;

namespace SemanticKernel.Service.Skills.OpenApiSkills.GitHubSkill.Model;

/// <summary>
/// Represents a GitHub Repo.
Expand All @@ -19,7 +21,6 @@ public class Repo
[JsonPropertyName("full_name")]
public string FullName { get; set; }


/// <summary>
/// Initializes a new instance of the <see cref="Repo"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace SemanticKernel.Service.Skills.OpenApiSkills;
namespace SemanticKernel.Service.Skills.OpenApiSkills.GitHubSkill.Model;

/// <summary>
/// Represents a user on GitHub.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ private static Plan NodeListToPlan(XmlNodeList nodes, SKContext context, string
}
else
{
if (string.IsNullOrEmpty(skillName) ?
!context.Skills!.TryGetFunction(functionName, out var _) :
!context.Skills!.TryGetFunction(skillName, functionName, out var _))
if (string.IsNullOrEmpty(skillName)
? !context.Skills!.TryGetFunction(functionName, out var _)
: !context.Skills!.TryGetFunction(skillName, functionName, out var _))
{
var planStep = new Plan(node.InnerText);
planStep.Parameters.Update(node.InnerText);
Expand Down

0 comments on commit 1b01049

Please sign in to comment.