-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement WindowsFormsApplicationBase.IsSingleInstance #3200
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
Conversation
...sualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.vb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the current Framework behavior. 2 files are considered the same if they only vary by last 2 version fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For projects coming from Framework the developer through VS creates the base value and VB runtime adds 2 additional version strings. If a project is still in Framework and runs on top of Core this behavior will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Entry.ManifestModule.ModuleVersionId.ToString() will make the Debug and Release version of the same source app different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if this were overridable so developers can select am appropriate algorithm with this being the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 👍
...oft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb
Outdated
Show resolved
Hide resolved
...oft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb
Outdated
Show resolved
Hide resolved
...oft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb
Outdated
Show resolved
Hide resolved
...oft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb
Outdated
Show resolved
Hide resolved
...sualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.vb
Outdated
Show resolved
Hide resolved
...oft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb
Outdated
Show resolved
Hide resolved
...oft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb
Outdated
Show resolved
Hide resolved
...oft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb
Outdated
Show resolved
Hide resolved
...oft.VisualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/SingleInstanceHelpers.vb
Outdated
Show resolved
Hide resolved
| If nRead = 0 Then | ||
| Exit While | ||
| End If | ||
| stream.Write(buffer, 0, nRead) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider WriteAsync here since this is already an Async method. #ByDesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stream here is a MemoryStream rather than the NamedPipeServerStream.
In reply to: 426088068 [](ancestors = 426088068)
Codecov Report
@@ Coverage Diff @@
## master #3200 +/- ##
====================================================
+ Coverage 33.28961% 63.05974% +29.77012%
====================================================
Files 883 1310 +427
Lines 253893 466288 +212395
Branches 36741 39798 +3057
====================================================
+ Hits 84520 294040 +209520
- Misses 164586 166853 +2267
- Partials 4787 5395 +608
|
...sualBasic.Forms/src/Microsoft/VisualBasic/ApplicationServices/WindowsFormsApplicationBase.vb
Outdated
Show resolved
Hide resolved
| If bytesRead = 0 Then | ||
| Exit While | ||
| End If | ||
| stream.Write(buffer, 0, bytesRead) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| stream.Write(buffer, 0, bytesRead) | |
| Await stream.WriteAsync(buffer, 0, bytesRead).ConfigureAwait(false) | |
| ``` #ByDesign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stream in this case is a MemoryStream so Write() should be equivalent to WriteAsync().
In reply to: 430663031 [](ancestors = 430663031)
| } | ||
| } | ||
|
|
||
| // Should be able to test internal methods with [InternalsVisibleTo] rather than reflection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're actually moving in the opposite direction - prefer reduce "internal" API surface (if it is only used for tests) and use reflection instead.
#3225
| TestHelpers.EndProcess(process0, timeout: 1000); | ||
| TestHelpers.EndProcess(process1, timeout: 1000); | ||
| Assert.True(process0.HasExited); | ||
| Assert.True(process1.HasExited); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we test that process1 exited on his own accord before trying to close it?
|
@msftbot merge if @jaredpar approves |
Fixes #2056
Fixes #3131
Proposed changes
Implement support for
WindowsFormsApplicationBasesingle-instance behavior.Customer Impact
Allows applications using the VisualBasic application model to opt-in to single-instance behavior.
Regression?
Not implemented when porting Microsoft.VisualBasic to .NET Core previously.
Risk
Medium risk when opted-in; low risk otherwise.
Test methodology
Unit tests.
Microsoft Reviewers: Open in CodeFlow