X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ jobs:
with:
dotnet-version: |
${{ env.dotnet_sdk_version }}
3.1.x

- name: Build
run: dotnet build -c ${{ matrix.config }}
Expand Down
7 changes: 0 additions & 7 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn> <!-- The target framework 'net5.0' is out of support -->
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<!-- In netstandard2.0, the BCL isn't annotated for nullability so we disable nullability there -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netcoreapp3.1'">
<Nullable>disable</Nullable>
<NoWarn>$(NoWarn);CS8632;CS8600</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)postgresql.png" Pack="true" PackagePath="" />
</ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
<PackageVersion Include="OpenTelemetry.API" Version="1.6.0" />

<!-- Compatibility -->
<PackageVersion Include="System.Threading.Channels" Version="$(SystemVersion)" />
<PackageVersion Include="System.Collections.Immutable" Version="$(SystemVersion)" />
<PackageVersion Include="System.Text.Json" Version="$(SystemVersion)" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="$(SystemVersion) " />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />

<!-- Plugin projects -->
Expand Down
5 changes: 2 additions & 3 deletions src/Npgsql/Internal/Converters/JsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,11 @@ public static bool TryReadStream(bool jsonb, Encoding encoding, PgReader reader,

var isUtf8 = encoding.CodePage == Encoding.UTF8.CodePage;
byteCount = reader.CurrentRemaining;
// We always fall back to buffers on older targets
if (isUtf8 || byteCount >= StreamingThreshold)
{
stream = !isUtf8
? Encoding.CreateTranscodingStream(reader.GetStream(), encoding, Encoding.UTF8)
: reader.GetStream();
? Encoding.CreateTranscodingStream(reader.GetStream(), encoding, Encoding.UTF8)
: reader.GetStream();
}
else
stream = null;
Expand Down
1 change: 0 additions & 1 deletion src/Npgsql/Internal/HackyEnumTypeMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Npgsql.Internal;

#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

/// <summary>
/// Hacky temporary measure used by EFCore.PG to extract user-configured enum mappings. Accessed via reflection only.
Expand Down
6 changes: 1 addition & 5 deletions src/Npgsql/Internal/NpgsqlConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ Task<IPAddress[]> GetHostAddressesAsync(CancellationToken ct) =>

static Task OpenSocketConnectionAsync(Socket socket, EndPoint endpoint, NpgsqlTimeout perIpTimeout, CancellationToken cancellationToken)
{
// Whether the framework and/or the OS platform support Socket.ConnectAsync cancellation API or they do not,
// Whether the OS platform supports Socket.ConnectAsync cancellation API or not,
// we always fake-cancel the operation with the help of TaskTimeoutAndCancellation.ExecuteAsync. It stops waiting
// and raises the exception, while the actual task may be left running.
Task ConnectAsync(CancellationToken ct) =>
Expand Down Expand Up @@ -2484,7 +2484,6 @@ internal void EndUserAction()

#region Keepalive

#pragma warning disable CA1801 // Review unused parameters
void PerformKeepAlive(object? state)
{
Debug.Assert(_isKeepAliveEnabled);
Expand Down Expand Up @@ -2523,7 +2522,6 @@ void PerformKeepAlive(object? state)
Monitor.Exit(SyncObj);
}
}
#pragma warning restore CA1801 // Review unused parameters

#endregion

Expand Down Expand Up @@ -2792,9 +2790,7 @@ enum ConnectorState
Replication,
}

#pragma warning disable CA1717
enum TransactionStatus : byte
#pragma warning restore CA1717
{
/// <summary>
/// Currently not in a transaction block
Expand Down
1 change: 0 additions & 1 deletion src/Npgsql/Internal/NpgsqlWriteBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Npgsql.Util;
using static System.Threading.Timeout;

#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
namespace Npgsql.Internal;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Npgsql/KerberosUsernameProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ sealed class KerberosUsernameProvider

return GetUsernameAsyncInternal();

#pragma warning disable CS1998
async ValueTask<string?> GetUsernameAsyncInternal()
#pragma warning restore CS1998
{
if (async)
await process.WaitForExitAsync(cancellationToken).ConfigureAwait(false);
Expand Down
10 changes: 1 addition & 9 deletions src/Npgsql/Npgsql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,8 @@
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Bcl.HashCode" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netstandard2.1' ">
<PackageReference Include="System.Threading.Channels" />
<PackageReference Include="System.Collections.Immutable" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netstandard2.1' OR '$(TargetFramework)' == 'net6.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="System.Text.Json" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" />
Expand Down
2 changes: 0 additions & 2 deletions src/Npgsql/NpgsqlBatchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public override string CommandText
/// <inheritdoc cref="DbBatchCommand.Parameters"/>
public new NpgsqlParameterCollection Parameters => _parameters ??= new();

#pragma warning disable CA1822 // Mark members as static

#if NET8_0_OR_GREATER
/// <inheritdoc/>
Expand All @@ -66,7 +65,6 @@ public bool CanCreateParameter
#endif
=> true;

#pragma warning restore CA1822 // Mark members as static

/// <summary>
/// Appends an error barrier after this batch command. Defaults to the value of <see cref="NpgsqlBatch.EnableErrorBarriers" /> on the
Expand Down
1 change: 0 additions & 1 deletion src/Npgsql/NpgsqlDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
using NpgsqlTypes;
using static Npgsql.Util.Statics;

#pragma warning disable CA2222 // Do not decrease inherited member visibility
namespace Npgsql;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Npgsql/NpgsqlDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ protected sealed override ValueTask DisposeAsyncCore()
return default;
}

#pragma warning disable CS1998
/// <inheritdoc cref="DisposeAsyncCore" />
protected virtual async ValueTask DisposeAsyncBase()
{
Expand All @@ -508,7 +507,6 @@ protected virtual async ValueTask DisposeAsyncBase()
// TODO: async Clear, #4499
Clear();
}
#pragma warning restore CS1998

private protected void CheckDisposed()
{
Expand Down
1 change: 0 additions & 1 deletion src/Npgsql/NpgsqlFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Data.Common;
using System.Diagnostics.CodeAnalysis;

namespace Npgsql;

Expand Down
4 changes: 0 additions & 4 deletions src/Npgsql/NpgsqlParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ public string? DataTypeName
[Category("Data")]
public sealed override ParameterDirection Direction { get; set; }

#pragma warning disable CS0109
/// <summary>
/// Gets or sets the maximum number of digits used to represent the <see cref="Value"/> property.
/// </summary>
Expand All @@ -444,7 +443,6 @@ public string? DataTypeName
get => _scale;
set => _scale = value;
}
#pragma warning restore CS0109

/// <inheritdoc />
[DefaultValue(0)]
Expand Down Expand Up @@ -478,12 +476,10 @@ public sealed override string SourceColumn
/// <inheritdoc />
public sealed override bool SourceColumnNullMapping { get; set; }

#pragma warning disable CA2227
/// <summary>
/// The collection to which this parameter belongs, if any.
/// </summary>
public NpgsqlParameterCollection? Collection { get; set; }
#pragma warning restore CA2227

/// <summary>
/// The PostgreSQL data type, such as int4 or text, as discovered from pg_type.
Expand Down
3 changes: 0 additions & 3 deletions src/Npgsql/NpgsqlTypes/NpgsqlTsQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Text;

#pragma warning disable CA1034

// ReSharper disable once CheckNamespace
namespace NpgsqlTypes;
Expand Down Expand Up @@ -470,10 +469,8 @@ public NpgsqlTsQueryLexeme(string text, Weight weights, bool isPrefixSearch)
/// <summary>
/// Weight enum, can be OR'ed together.
/// </summary>
#pragma warning disable CA1714
[Flags]
public enum Weight
#pragma warning restore CA1714
{
/// <summary>
/// None
Expand Down
1 change: 0 additions & 1 deletion src/Npgsql/NpgsqlTypes/NpgsqlTsVector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.Text;

#pragma warning disable CA1040, CA1034
// ReSharper disable once CheckNamespace
namespace NpgsqlTypes;

Expand Down
2 changes: 0 additions & 2 deletions src/Npgsql/PostgresTypes/PostgresUnknownType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ public sealed class UnknownBackendType : PostgresType
/// <summary>
/// Constructs a the unknown backend type.
/// </summary>
#pragma warning disable CA2222 // Do not decrease inherited member visibility
UnknownBackendType() : base("", "<unknown>", 0) { }
#pragma warning restore CA2222 // Do not decrease inherited member visibility
}
2 changes: 0 additions & 2 deletions src/Npgsql/PregeneratedMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ static class PregeneratedMessages
{
static PregeneratedMessages()
{
#pragma warning disable CS8625
// This is the only use of a write buffer without a connector, for in-memory construction of
// pregenerated messages.
using var buf = new NpgsqlWriteBuffer(null, new MemoryStream(), null, NpgsqlWriteBuffer.MinimumSize, Encoding.ASCII);
#pragma warning restore CS8625

BeginTransRepeatableRead = Generate(buf, "BEGIN ISOLATION LEVEL REPEATABLE READ");
BeginTransSerializable = Generate(buf, "BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE");
Expand Down
4 changes: 0 additions & 4 deletions src/Shared/CodeAnalysis.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Diagnostics.CodeAnalysis;

#pragma warning disable 1591

namespace System.Diagnostics.CodeAnalysis
{
Expand Down
11 changes: 1 addition & 10 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project>
<Import Project="../Directory.Build.props" />

<PropertyGroup>
Expand All @@ -9,15 +9,6 @@
<NoWarn>$(NoWarn);CA2252</NoWarn>
</PropertyGroup>

<!--
We use the netcoreapp3.1 TFM to tests compatibility with netstandard2.0 but may of the the packages issue warnings
because they have not been tested with netcoreapp3.1.
Since testing for compatibility is exactly what we want to do here, we disable the warnings.
-->
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1'">
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" />
</ItemGroup>
Expand Down
6 changes: 1 addition & 5 deletions test/Npgsql.Tests/ConnectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,8 @@ public async Task Reload_types_keepalive_concurrent()

var startTimestamp = Stopwatch.GetTimestamp();
// Give a few seconds for a KeepAlive to possibly perform
while (GetElapsedTime(startTimestamp).TotalSeconds < 2)
while (Stopwatch.GetElapsedTime(startTimestamp).TotalSeconds < 2)
Assert.DoesNotThrow(conn.ReloadTypes);

// dotnet 3.1 doesn't have Stopwatch.GetElapsedTime method.
static TimeSpan GetElapsedTime(long startingTimestamp) =>
new((long)((Stopwatch.GetTimestamp() - startingTimestamp) * ((double)10000000 / Stopwatch.Frequency)));
}

#region ChangeDatabase
Expand Down
3 changes: 0 additions & 3 deletions test/Npgsql.Tests/ExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ PostgresException CreateWithSqlState(string sqlState)

#pragma warning disable SYSLIB0011
#pragma warning disable SYSLIB0050
#pragma warning disable 618
[Test]
public void Serialization()
{
Expand Down Expand Up @@ -286,9 +285,7 @@ public void Serialization()
}

SerializationInfo CreateSerializationInfo() => new(typeof(PostgresException), new FormatterConverter());
#pragma warning restore 618
#pragma warning restore SYSLIB0011
#pragma warning disable SYSLIB0050

#pragma warning disable SYSLIB0051
[Test]
Expand Down
4 changes: 0 additions & 4 deletions test/Npgsql.Tests/MultipleHostsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ public async Task Valid_host_not_found(TargetSessionAttributes targetSessionAttr
[Test, Platform(Exclude = "MacOsX", Reason = "#3786")]
public void All_hosts_are_down()
{
// Different exception raised in .NET Core 3.1, skip (NUnit doesn't seem to support detecting .NET Core versions)
if (RuntimeInformation.FrameworkDescription.StartsWith(".NET Core 3.1"))
return;

var endpoint = new IPEndPoint(IPAddress.Loopback, 0);

using var socket1 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Expand Down
2 changes: 0 additions & 2 deletions test/Npgsql.Tests/ReadBufferTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,13 @@ public async Task ReadNullTerminatedString_with_io()
Assert.That(ReadBuffer.ReadNullTerminatedString(), Is.EqualTo("bar"));
}

#pragma warning disable CS8625
[SetUp]
public void SetUp()
{
var stream = new MockStream();
ReadBuffer = new NpgsqlReadBuffer(null, stream, null, NpgsqlReadBuffer.DefaultSize, NpgsqlWriteBuffer.UTF8Encoding, NpgsqlWriteBuffer.RelaxedUTF8Encoding);
Writer = stream.Writer;
}
#pragma warning restore CS8625

// ReSharper disable once InconsistentNaming
NpgsqlReadBuffer ReadBuffer = default!;
Expand Down
2 changes: 0 additions & 2 deletions test/Npgsql.Tests/TypesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,11 @@ public void Bug1011018()
var o = p.Value;
}

#pragma warning disable 618
[Test]
[IssueLink("https://github.com/npgsql/npgsql/issues/750")]
public void NpgsqlInet()
{
var v = new NpgsqlInet(IPAddress.Parse("2001:1db8:85a3:1142:1000:8a2e:1370:7334"), 32);
Assert.That(v.ToString(), Is.EqualTo("2001:1db8:85a3:1142:1000:8a2e:1370:7334/32"));
}
#pragma warning restore 618
}
2 changes: 0 additions & 2 deletions test/Npgsql.Tests/WriteBufferTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,12 @@ public void Chunked_char_array_encoding_fits_with_surrogates()
Assert.That(completed, Is.False);
}

#pragma warning disable CS8625
[SetUp]
public void SetUp()
{
Underlying = new MemoryStream();
WriteBuffer = new NpgsqlWriteBuffer(null, Underlying, null, NpgsqlReadBuffer.DefaultSize, NpgsqlWriteBuffer.UTF8Encoding);
}
#pragma warning restore CS8625

// ReSharper disable once InconsistentNaming
NpgsqlWriteBuffer WriteBuffer = default!;
Expand Down
X Tutup