Skip to content

Commit

Permalink
Optimize a few things further.
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 23d615b commit 6c156db
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions src/IDisposableGenerator/DisposableCodeWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ Implements IDisposable
Private isDisposed As Boolean
");

if (classItem.Owns.Count is not 0 && !classItem.Stream)
{
_ = sourceBuilder.Append(@"
Friend Property IsOwned As Boolean
");
}
else if (classItem.Owns.Count is not 0 && classItem.Stream)
if (classItem.Owns.Count is not 0)
{
_ = sourceBuilder.Append(@"
_ = sourceBuilder.Append(classItem.Stream ? @"
Friend ReadOnly Property KeepOpen As Boolean
" : @"
Friend Property IsOwned As Boolean
");
}

Expand Down Expand Up @@ -135,16 +131,12 @@ namespace {workItem.Namespace};
{{
private bool isDisposed;
");
if (classItem.Owns.Count is not 0 && !classItem.Stream)
{
_ = sourceBuilder.Append(@"
internal bool IsOwned { get; set; }
");
}
else if (classItem.Owns.Count is not 0 && classItem.Stream)
if (classItem.Owns.Count is not 0)
{
_ = sourceBuilder.Append(@"
_ = sourceBuilder.Append(classItem.Stream ? @"
internal bool KeepOpen { get; }
" : @"
internal bool IsOwned { get; set; }
");
}

Expand Down Expand Up @@ -249,16 +241,12 @@ namespace {workItem.Namespace}
{{
private bool isDisposed;
");
if (classItem.Owns.Count is not 0 && !classItem.Stream)
{
_ = sourceBuilder.Append(@"
internal bool IsOwned { get; set; }
");
}
else if (classItem.Owns.Count is not 0 && classItem.Stream)
if (classItem.Owns.Count is not 0)
{
_ = sourceBuilder.Append(@"
_ = sourceBuilder.Append(classItem.Stream ? @"
internal bool KeepOpen { get; }
" : @"
internal bool IsOwned { get; set; }
");
}

Expand Down

0 comments on commit 6c156db

Please sign in to comment.