Skip to content

Commit

Permalink
Replace calls to .Any() with .Count is not 0.
Browse files Browse the repository at this point in the history
Signed-off-by: AraHaan <[email protected]>
  • Loading branch information
AraHaan committed Feb 23, 2024
1 parent f521889 commit de5eb2b
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/IDisposableGenerator/DisposableCodeWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Implements IDisposable
Private isDisposed As Boolean
");

if (classItem.Owns.Any() && !classItem.Stream)
if (classItem.Owns.Count is not 0 && !classItem.Stream)
{
_ = sourceBuilder.Append(@"
Friend Property IsOwned As Boolean
");
}
else if (classItem.Owns.Any() && classItem.Stream)
else if (classItem.Owns.Count is not 0 && classItem.Stream)
{
_ = sourceBuilder.Append(@"
Friend ReadOnly Property KeepOpen As Boolean
Expand All @@ -49,7 +49,7 @@ End Sub
Protected Overrides")} Sub Dispose(ByVal disposing As Boolean)
If Not Me.isDisposed AndAlso disposing Then
");
if (classItem.Methods.Any())
if (classItem.Methods.Count is not 0)
{
foreach (var methodItem in classItem.Methods)
{
Expand All @@ -58,7 +58,7 @@ If Not Me.isDisposed AndAlso disposing Then
}
}

if (classItem.Owns.Any())
if (classItem.Owns.Count is not 0)
{
_ = sourceBuilder.Append($@" If {(classItem.Stream ? "Not Me.KeepOpen" : "Me.IsOwned")} Then
");
Expand All @@ -74,7 +74,7 @@ If Not Me.isDisposed AndAlso disposing Then
");
}

if (classItem.Fields.Any())
if (classItem.Fields.Count is not 0)
{
foreach (var fieldItem in classItem.Fields)
{
Expand All @@ -85,7 +85,7 @@ If Not Me.isDisposed AndAlso disposing Then
}
}

if (classItem.SetNull.Any())
if (classItem.SetNull.Count is not 0)
{
foreach (var nullItem in classItem.SetNull)
{
Expand Down Expand Up @@ -135,13 +135,13 @@ namespace {workItem.Namespace};
{{
private bool isDisposed;
");
if (classItem.Owns.Any() && !classItem.Stream)
if (classItem.Owns.Count is not 0 && !classItem.Stream)
{
_ = sourceBuilder.Append(@"
internal bool IsOwned { get; set; }
");
}
else if (classItem.Owns.Any() && classItem.Stream)
else if (classItem.Owns.Count is not 0 && classItem.Stream)
{
_ = sourceBuilder.Append(@"
internal bool KeepOpen { get; }
Expand All @@ -160,7 +160,7 @@ namespace {workItem.Namespace};
if (!this.isDisposed && disposing)
{{
");
if (classItem.Methods.Any())
if (classItem.Methods.Count is not 0)
{
foreach (var methodItem in classItem.Methods)
{
Expand All @@ -169,7 +169,7 @@ namespace {workItem.Namespace};
}
}

if (classItem.Owns.Any())
if (classItem.Owns.Count is not 0)
{
_ = sourceBuilder.Append($@" if ({(classItem.Stream ? "!this.KeepOpen" : "this.IsOwned")})
{{
Expand All @@ -186,7 +186,7 @@ namespace {workItem.Namespace};
");
}

if (classItem.Fields.Any())
if (classItem.Fields.Count is not 0)
{
foreach (var fieldItem in classItem.Fields)
{
Expand All @@ -197,7 +197,7 @@ namespace {workItem.Namespace};
}
}

if (classItem.SetNull.Any())
if (classItem.SetNull.Count is not 0)
{
foreach (var nullItem in classItem.SetNull)
{
Expand Down Expand Up @@ -249,13 +249,13 @@ namespace {workItem.Namespace}
{{
private bool isDisposed;
");
if (classItem.Owns.Any() && !classItem.Stream)
if (classItem.Owns.Count is not 0 && !classItem.Stream)
{
_ = sourceBuilder.Append(@"
internal bool IsOwned { get; set; }
");
}
else if (classItem.Owns.Any() && classItem.Stream)
else if (classItem.Owns.Count is not 0 && classItem.Stream)
{
_ = sourceBuilder.Append(@"
internal bool KeepOpen { get; }
Expand All @@ -274,7 +274,7 @@ namespace {workItem.Namespace}
if (!this.isDisposed && disposing)
{{
");
if (classItem.Methods.Any())
if (classItem.Methods.Count is not 0)
{
foreach (var methodItem in classItem.Methods)
{
Expand All @@ -283,7 +283,7 @@ namespace {workItem.Namespace}
}
}

if (classItem.Owns.Any())
if (classItem.Owns.Count is not 0)
{
_ = sourceBuilder.Append($@" if ({(classItem.Stream ? "!this.KeepOpen" : "this.IsOwned")})
{{
Expand All @@ -300,7 +300,7 @@ namespace {workItem.Namespace}
");
}

if (classItem.Fields.Any())
if (classItem.Fields.Count is not 0)
{
foreach (var fieldItem in classItem.Fields)
{
Expand All @@ -311,7 +311,7 @@ namespace {workItem.Namespace}
}
}

if (classItem.SetNull.Any())
if (classItem.SetNull.Count is not 0)
{
foreach (var nullItem in classItem.SetNull)
{
Expand Down

0 comments on commit de5eb2b

Please sign in to comment.