Skip to content

Commit

Permalink
Merge pull request #228 from dvonthenen/linting-dotnet-analyzer
Browse files Browse the repository at this point in the history
Linter Updates From .NET Analyzers
  • Loading branch information
davidvonthenen authored Feb 12, 2024
2 parents 5e4b10c + d19ac8f commit 16fae96
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 36 deletions.
9 changes: 4 additions & 5 deletions Deepgram.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

global using System.Net;
global using System.Text;
global using System.Text.Json;
global using System.Web;
global using AutoBogus;
global using Bogus;
global using Deepgram.Abstractions;
Expand All @@ -15,6 +11,9 @@
global using Deepgram.Utilities;
global using FluentAssertions;
global using FluentAssertions.Execution;
global using Microsoft.Extensions.DependencyInjection;
global using NSubstitute;
global using NUnit.Framework;
global using System.Net;
global using System.Text;
global using System.Text.Json;
global using System.Web;
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// SPDX-License-Identifier: MIT

using Deepgram.Encapsulations;
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.Manage.v1;
using Deepgram.Models.PreRecorded.v1;
using Deepgram.Models.Authenticate.v1;

namespace Deepgram.Tests.UnitTests.ClientTests;

Expand Down
4 changes: 2 additions & 2 deletions Deepgram.Tests/UnitTests/ClientTests/LiveClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

using System.Net.WebSockets;
using Deepgram.DeepgramEventArgs;
using Deepgram.Models.Live.v1;
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.Live.v1;
using System.Net.WebSockets;

namespace Deepgram.Tests.UnitTests.ClientTests;

Expand Down
2 changes: 1 addition & 1 deletion Deepgram.Tests/UnitTests/ClientTests/ManageClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// SPDX-License-Identifier: MIT

using Deepgram.Encapsulations;
using Deepgram.Models.Manage.v1;
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.Manage.v1;

namespace Deepgram.Tests.UnitTests.ClientTests;

Expand Down
2 changes: 1 addition & 1 deletion Deepgram.Tests/UnitTests/ClientTests/OnPremClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// SPDX-License-Identifier: MIT

using Deepgram.Encapsulations;
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.Manage.v1;
using Deepgram.Models.OnPrem.v1;
using Deepgram.Models.Authenticate.v1;

namespace Deepgram.Tests.UnitTests.ClientTests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// SPDX-License-Identifier: MIT

using Deepgram.Encapsulations;
using Deepgram.Models.PreRecorded.v1;
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.PreRecorded.v1;

namespace Deepgram.Tests.UnitTests.ClientTests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

using Deepgram.Models.Manage.v1;
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.Manage.v1;

namespace Deepgram.Tests.UnitTests.ExtensionsTests;
public class HttpClientExtensionTests
Expand Down
2 changes: 1 addition & 1 deletion Deepgram/Abstractions/AbstractRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public virtual async Task<T> PatchAsync<T>(string uriSegment, StringContent cont
{
#if NETSTANDARD2_0
var request = new HttpRequestMessage(new HttpMethod("PATCH"), uriSegment) { Content = content };
var response = await _httpClientWrapper.SendAsync(request,cancellationToken);
var response = await _httpClientWrapper.SendAsync(request, cancellationToken);
#else
var req = new HttpRequestMessage(HttpMethod.Patch, uriSegment) { Content = content };
var response = await _httpClientWrapper.SendAsync(req, cancellationToken);
Expand Down
4 changes: 0 additions & 4 deletions Deepgram/Constants/Defaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ namespace Deepgram.Constants;

public static class Defaults
{

public const string DEFAULT_URI = "api.deepgram.com";
public const string HTTPCLIENT_NAME = "DEEPGRAM_HTTP_CLIENT";
public const string WSSCLIENT_NAME = "DEEPGRAM_WSS_CLIENT";
public const string DEFAULT_CONTENT_TYPE = "application/json";
public const string DEEPGRAM_CONTENT_TYPE = "deepgram/audio+video";


}
23 changes: 17 additions & 6 deletions Deepgram/Deepgram.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/deepgram-devs/deepgram-dotnet-sdk</RepositoryUrl>
<PackageTags>speech-to-text,captions,speech-recognition,deepgram,dotnet</PackageTags>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
Expand All @@ -37,13 +40,13 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.*" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.*" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.1" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageReference Include="System.Text.Json" Version="6.*" />
<PackageReference Include="System.Threading.Channels" Version="6.*" />
<PackageReference Include="System.Text.Json" Version="8.0.1" />
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
Expand Down Expand Up @@ -83,4 +86,12 @@
<InternalsVisibleTo Include="Deepgram.Tests" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions Deepgram/Encapsulations/HttpClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Deepgram.Models.Authenticate.v1;

namespace Deepgram.Encapsulations;

internal class HttpClientFactory
{
public static HttpClientWrapper Create(string apiKey, DeepgramClientOptions deepgramClientOptions)
Expand Down
1 change: 1 addition & 0 deletions Deepgram/Enums/LiveType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT

namespace Deepgram.Enums;

public enum LiveType
{
Metadata,
Expand Down
2 changes: 1 addition & 1 deletion Deepgram/LiveClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// SPDX-License-Identifier: MIT

using Deepgram.Extensions;
using Deepgram.Models.Live.v1;
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.Live.v1;

namespace Deepgram;

Expand Down
4 changes: 0 additions & 4 deletions Deepgram/Logger/LogProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@ public static ILogger GetLogger(string category)
// Return the logger
return logger;
}




}
2 changes: 1 addition & 1 deletion Deepgram/ManageClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

using Deepgram.Models.Manage.v1;
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.Manage.v1;

namespace Deepgram;

Expand Down
2 changes: 1 addition & 1 deletion Deepgram/OnPremClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.Manage.v1;
using Deepgram.Models.OnPrem.v1;
using Deepgram.Models.Authenticate.v1;

namespace Deepgram;

Expand Down
2 changes: 1 addition & 1 deletion Deepgram/PrerecordedClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

using Deepgram.Models.PreRecorded.v1;
using Deepgram.Models.Authenticate.v1;
using Deepgram.Models.PreRecorded.v1;

namespace Deepgram;

Expand Down
6 changes: 1 addition & 5 deletions Deepgram/Utilities/RequestContentUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ internal static class RequestContentUtil
internal static StringContent CreatePayload<T>(T body)
{
var serialized = JsonSerializer.Serialize(body, _jsonSerializerOptions);
return new(
serialized,
Encoding.UTF8,
Defaults.DEFAULT_CONTENT_TYPE);
return new(serialized, Encoding.UTF8, Defaults.DEFAULT_CONTENT_TYPE);
}


Expand All @@ -37,7 +34,6 @@ internal static HttpContent CreateStreamPayload(Stream body)
{
body.Seek(0, SeekOrigin.Begin);
HttpContent httpContent = new StreamContent(body);
httpContent.Headers.Add("Content-Type", Defaults.DEEPGRAM_CONTENT_TYPE);
httpContent.Headers.Add("Content-Length", body.Length.ToString());
return httpContent;
}
Expand Down

0 comments on commit 16fae96

Please sign in to comment.