Skip to content

Test: dispose DirectoryService#845

Merged
dtivel merged 2 commits intomainfrom
dtivel/dispose-directoryservice
Apr 3, 2025
Merged

Test: dispose DirectoryService#845
dtivel merged 2 commits intomainfrom
dtivel/dispose-directoryservice

Conversation

@dtivel
Copy link
Collaborator

@dtivel dtivel commented Apr 1, 2025

This change ensures that the DirectoryService is properly disposed of after use. This ensures test files are deleted after test execution.

Also, some very minor reformatting changes.

Use https://github.com/dotnet/sign/pull/845/files?w=1 to ignore whitespace changes.

@dtivel dtivel requested a review from a team as a code owner April 1, 2025 21:53
Copy link

@jeffkl jeffkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If every test needs a TemporaryDirectory, consider adding a base class that all tests inherit from which gets a lazy temp directory and disposes of it. That way all tests would follow the same pattern.

https://github.com/microsoft/slngen/blob/main/src/Microsoft.VisualStudio.SlnGen.UnitTests/TestBase.cs#L69

@dtivel
Copy link
Collaborator Author

dtivel commented Apr 2, 2025

@jeffkl, thanks for the feedback. Not every test needs a TemporaryDirectory. Another approach in the same vein would be to create a test fixture, which is shared amongst test classes that need it. The test fixture will be created once and disposed once. I'll implement that in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants