Skip to content

Commit

Permalink
[fix] Warning
Browse files Browse the repository at this point in the history
  • Loading branch information
eaba committed Jan 24, 2024
1 parent 46e64b1 commit fc19570
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/SharpPulsar.Test.API/Schema/KeyValueSchemaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public virtual void TestSeparatedKeyValueEncodingTypeSchemaEncodeAndDecode()
try
{
keyValueSchema.Decode(encodeBytes);
Assert.True(false, "This method cannot be used under this SEPARATED encoding type");
Assert.Fail("This method cannot be used under this SEPARATED encoding type");
}
catch (SchemaSerializationException e)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SharpPulsar.Test/AutoClusterFailoverTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class AutoClusterFailoverTest : IAsyncLifetime

private PulsarClient _client;
private readonly ITestOutputHelper _output;
private TaskCompletionSource<PulsarClient> _tcs;
//private TaskCompletionSource<PulsarClient> _tcs;
private PulsarSystem _system;
private PulsarClientConfigBuilder _configBuilder;
public AutoClusterFailoverTest(ITestOutputHelper output, PulsarFixture fixture)
Expand Down
3 changes: 2 additions & 1 deletion src/SharpPulsar.Test/GenericSchemaTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Avro.Generic;
using SharpPulsar.Builder;
Expand Down Expand Up @@ -85,7 +86,7 @@ private byte[] ToBytes<T>(T obj)
return null;

return JsonSerializer.SerializeToUtf8Bytes(obj,
new JsonSerializerOptions { WriteIndented = false, IgnoreNullValues = true });
new JsonSerializerOptions { WriteIndented = false, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull});
}

// Convert a byte array to an Object
Expand Down
4 changes: 2 additions & 2 deletions src/SharpPulsar.Test/TableViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task TestTableView()
var count = 20;
var keys = await PublishMessages(topic, count, false);

var tv = await _client.NewTableViewBuilder(ISchema<string>.Bytes)
var tv = await _client.NewTableView(ISchema<string>.Bytes)
.Topic(topic)
.AutoUpdatePartitionsInterval(TimeSpan.FromSeconds(60))
.CreateAsync();
Expand Down Expand Up @@ -83,7 +83,7 @@ public async Task TestTableViewUpdatePartitions()
var count = 20;
var keys = await PublishMessages(topic, count, false);

var tv = await _client.NewTableViewBuilder(ISchema<string>.Bytes).Topic(topic)
var tv = await _client.NewTableView(ISchema<string>.Bytes).Topic(topic)
.AutoUpdatePartitionsInterval(TimeSpan.FromSeconds(5)).CreateAsync();

_output.WriteLine($"start tv size: {tv.Size}");
Expand Down
60 changes: 30 additions & 30 deletions src/SharpPulsar.TimeUnit/TimeUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,16 @@ private TimeUnit(string value,
Func<long, long, int> excessNanos
)
{
this.Value = value;
this._ToNanos = toNanos;
this._ToTicks = toTicks;
this._ToMicros = toMicros;
this._ToMillis = toMillis;
this._ToSeconds = toSeconds;
this._ToMinutes = toMinutes;
this._ToHours = toHours;
this._ToDays = toDays;
this._ExcessNanos = excessNanos;
Value = value;
_ToNanos = toNanos;
_ToTicks = toTicks;
_ToMicros = toMicros;
_ToMillis = toMillis;
_ToSeconds = toSeconds;
_ToMinutes = toMinutes;
_ToHours = toHours;
_ToDays = toDays;
_ExcessNanos = excessNanos;
}

#endregion
Expand All @@ -208,7 +208,7 @@ public void Sleep(long timeout)
{
if (timeout > 0)
{
long Milliseconds = this.ToMilliseconds(timeout);
long Milliseconds = ToMilliseconds(timeout);
Thread.Sleep((int)Milliseconds);
}
}
Expand All @@ -223,7 +223,7 @@ public void TimedJoin(Thread thread, long timeout)
{
if (timeout > 0)
{
long Milliseconds = this.ToMilliseconds(timeout);
long Milliseconds = ToMilliseconds(timeout);
thread.Join((int)Milliseconds);
}
}
Expand All @@ -247,49 +247,49 @@ public void TimedWait(Object obj, long timeout)
{
if (timeout > 0)
{
long Milliseconds = this.ToMilliseconds(timeout);
long Milliseconds = ToMilliseconds(timeout);
Monitor.Wait(obj, (int)Milliseconds);
}
}

public long ToNanoseconds(long duration)
{
return this._ToNanos(duration);
return _ToNanos(duration);
}

public long ToTicks(long duration)
{
return this._ToTicks(duration);
return _ToTicks(duration);
}

public long ToMicroseconds(long duration)
{
return this._ToMicros(duration);
return _ToMicros(duration);
}

public long ToMilliseconds(long duration)
{
return this._ToMillis(duration);
return _ToMillis(duration);
}

public long ToSeconds(long duration)
{
return this._ToSeconds(duration);
return _ToSeconds(duration);
}

public long ToMinutes(long duration)
{
return this._ToMinutes(duration);
return _ToMinutes(duration);
}

public long ToHours(long duration)
{
return this._ToHours(duration);
return _ToHours(duration);
}

public long ToDays(long duration)
{
return this._ToDays(duration);
return _ToDays(duration);
}

/// <summary>
Expand All @@ -307,7 +307,7 @@ public long ToDays(long duration)
/// positively overflow</returns>
public long Convert(long sourceDuration, TimeUnit sourceUnit)
{
switch (this.Value)
switch (Value)
{
case _DAYS:
{
Expand Down Expand Up @@ -343,36 +343,36 @@ public long Convert(long sourceDuration, TimeUnit sourceUnit)
}
default:
{
throw new ArgumentException($"The time unit {this.Value} is unrecognized.");
throw new ArgumentException($"The time unit {Value} is unrecognized.");
}
}
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(this, obj))
{
return true;
}

if (obj == null || this.GetType() != obj.GetType())
if (obj == null || GetType() != obj.GetType())
{
return false;
}

TimeUnit Other = (TimeUnit)obj;
TimeUnit? Other = (TimeUnit)obj;

return this.Value == Other.Value;
return Value == Other.Value;
}

public override string ToString()
{
return this.Value;
return Value;
}

public override int GetHashCode()
{
return Hashing.Hash(this.Value);
return Hashing.Hash(Value);
}

public static bool operator ==(TimeUnit left, TimeUnit right)
Expand Down Expand Up @@ -407,7 +407,7 @@ public override int GetHashCode()
/// <returns>The number of excess nanoseconds</returns>
private int ExcessNanos(long duration, long milliseconds)
{
return this._ExcessNanos(duration, milliseconds);
return _ExcessNanos(duration, milliseconds);
}

/// <summary>
Expand Down

0 comments on commit fc19570

Please sign in to comment.