Skip to content

Implementation of Chapter10 process exit PR #148 #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update 10.20 to match book and update test as well
  • Loading branch information
BenjaminMichaelis committed Jan 21, 2021
commit 0c4cc2f4b2ef3c6b0f6487ff345e559115f6d472
2 changes: 1 addition & 1 deletion src/Chapter10.Tests/Listing10.20.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private static void DeleteTempFile()
public void Create_GivenNewDocument_FileGetsCreated()
{
TemporaryFileStream fileStream = new TemporaryFileStream(TempFileName);
Assert.IsTrue(File.Exists(fileStream.File.FullName));
Assert.IsTrue(File.Exists(fileStream.File?.FullName!));
}

[TestMethod]
Expand Down
15 changes: 12 additions & 3 deletions src/Chapter10/Listing10.20.DefiningAFinalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,22 @@ public TemporaryFileStream()
}
}

public FileStream Stream { get; }
public FileInfo File { get; }
public FileStream Stream { get; private set; }
public FileInfo File { get; private set; }

public void Close()
{
Stream?.Dispose();
File?.Delete();
try
{
File?.Delete();
}
catch(IOException exception)
{
Console.WriteLine(exception);
}
Stream = null;
File = null;
}
}
}