Skip to content

+semver:minor Explicitly set UseShellExecute, .net core default changed#1457

Merged
andrew-polk merged 1 commit intomasterfrom
netCore_useShellExecute
Sep 5, 2025
Merged

+semver:minor Explicitly set UseShellExecute, .net core default changed#1457
andrew-polk merged 1 commit intomasterfrom
netCore_useShellExecute

Conversation

@nabalone
Copy link
Contributor

@nabalone nabalone commented Aug 29, 2025

UseShellExecute defaults to true in .net framework (including .net 4) and to false in .net core (including .net 8). Set it explicitly for consistency


This change is Reviewable

@nabalone nabalone marked this pull request as draft August 29, 2025 14:19
@github-actions
Copy link

github-actions bot commented Aug 29, 2025

Palaso Tests

     4 files  ±0       4 suites  ±0   9m 45s ⏱️ -18s
 5 045 tests ±0   4 811 ✅ ±0  234 💤 ±0  0 ❌ ±0 
16 435 runs  ±0  15 714 ✅ ±0  721 💤 ±0  0 ❌ ±0 

Results for commit b1f4e2a. ± Comparison against base commit cacf9d8.

♻️ This comment has been updated with latest results.

@nabalone nabalone marked this pull request as ready for review August 29, 2025 14:25
@tombogle
Copy link
Contributor

I don't expect this to break any of my software, but I'm curious: it looks like every single change notes that we didn't investigate whether the change was needed in that place. I would have expected there to be at least one pace where the change was being made because of a known need.

// UseShellExecute defaults to true in .net framework (including .net 4) and to false in .net core (including .net 8)
// We are explicitly setting it to true for consistency with the old behavior
// but have not checked if it is necessary here.
var prs = new Process { StartInfo = { FileName = exePath, Arguments = args, UseShellExecute = true } };

Check warning

Code scanning / CodeQL

Missing Dispose call on local IDisposable Warning

Disposable 'Process' is created but not disposed.

Copilot Autofix

AI 6 months ago

To fix the missing Dispose call for the local Process object, ensure that the object is disposed of as soon as it is no longer needed. The best practice is to wrap its lifetime in a using statement, which guarantees disposal even in case of exceptions. If LaunchArchivingProgram(prs) returns only after the process object is no longer needed (i.e., does not retain a reference), wrap the construction and usage in a using block here. Otherwise, ensure disposal happens in LaunchArchivingProgram. Since we only control the lines shown here and CodeQL flags this site, it is best to use a local using statement:

Change:

176: var prs = new Process { StartInfo = { FileName = exePath, Arguments = args, UseShellExecute = true } };
177: 
178: LaunchArchivingProgram(prs);

to:

176: using (var prs = new Process { StartInfo = { FileName = exePath, Arguments = args, UseShellExecute = true } })
177: {
178:     LaunchArchivingProgram(prs);
179: }

This ensures prs is disposed after LaunchArchivingProgram returns.

No extra imports or method definitions are necessary, just the use of a using block.


Suggested changeset 1
SIL.Archiving/IMDI/IMDIArchivingDlgViewModel.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/SIL.Archiving/IMDI/IMDIArchivingDlgViewModel.cs b/SIL.Archiving/IMDI/IMDIArchivingDlgViewModel.cs
--- a/SIL.Archiving/IMDI/IMDIArchivingDlgViewModel.cs
+++ b/SIL.Archiving/IMDI/IMDIArchivingDlgViewModel.cs
@@ -173,9 +173,10 @@
 			// UseShellExecute defaults to true in .net framework (including .net 4) and to false in .net core (including .net 8)
 			// We are explicitly setting it to true for consistency with the old behavior
 			// but have not checked if it is necessary here.
-			var prs = new Process { StartInfo = { FileName = exePath, Arguments = args, UseShellExecute = true } };
-
-			LaunchArchivingProgram(prs);
+			using (var prs = new Process { StartInfo = { FileName = exePath, Arguments = args, UseShellExecute = true } })
+			{
+				LaunchArchivingProgram(prs);
+			}
 		}
 
 #region Create IMDI package asynchronously
EOF
@@ -173,9 +173,10 @@
// UseShellExecute defaults to true in .net framework (including .net 4) and to false in .net core (including .net 8)
// We are explicitly setting it to true for consistency with the old behavior
// but have not checked if it is necessary here.
var prs = new Process { StartInfo = { FileName = exePath, Arguments = args, UseShellExecute = true } };

LaunchArchivingProgram(prs);
using (var prs = new Process { StartInfo = { FileName = exePath, Arguments = args, UseShellExecute = true } })
{
LaunchArchivingProgram(prs);
}
}

#region Create IMDI package asynchronously
Copilot is powered by AI and may make mistakes. Always verify output.
@nabalone nabalone force-pushed the netCore_useShellExecute branch from 0e991e9 to b1f4e2a Compare September 4, 2025 20:18
Copy link
Contributor Author

@nabalone nabalone left a comment

Choose a reason for hiding this comment

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

My mistake. I have corrected the comments

Reviewable status: 0 of 16 files reviewed, 1 unresolved discussion

Copy link
Contributor

@tombogle tombogle left a comment

Choose a reason for hiding this comment

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

@tombogle reviewed 15 of 16 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @nabalone)

@nabalone nabalone force-pushed the netCore_useShellExecute branch from b1f4e2a to 36ff067 Compare September 5, 2025 15:14
@andrew-polk andrew-polk merged commit 8c1f89c into master Sep 5, 2025
10 of 11 checks passed
@andrew-polk andrew-polk deleted the netCore_useShellExecute branch September 5, 2025 15:21
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.

3 participants