Skip to content
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

Code Style #135

Merged
merged 1 commit into from
Nov 5, 2024
Merged

Code Style #135

merged 1 commit into from
Nov 5, 2024

Conversation

dimonovdd
Copy link
Owner

Description

I did a little work on the code style

PR Checklist

  • All projects build
  • Has samples
  • Rebased onto current main

code style

upd editor config

usings

fix _

fix editorconfig
@dimonovdd dimonovdd requested a review from beeradmoore November 4, 2024 10:52
Copy link
Collaborator

@beeradmoore beeradmoore left a comment

Choose a reason for hiding this comment

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

Looks good.

I was so very confused about the await using in

await using var fileStream = System.IO.File.OpenRead(filePath);

on account of OpenRead not being async. It just returns a FileStream, which itself is an object not async thing itself. Even removing the await my IDE was like "hey you should add await here".

I had not used this syntax before (but I have used something like similar which is using (var file = myObject.OpenFileAsync('...'));) and wanted to understand it to make sure it is correct here.

What I found is await using is meaning that the object returned must implement IAsyncDisposable, something I also hadn't seen before. It turns out the FileStream class is a subclass of Stream class, which itself is IAsuncDisposable.

I use File.OpenRead in other projects but it hasn't tried to prompt me for the change there. This has given me something to go look into to see why.

@dimonovdd dimonovdd merged commit 4c93fd8 into main Nov 5, 2024
@dimonovdd dimonovdd deleted the code-style branch November 5, 2024 19:45
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.

2 participants