Hi
Consider the following piece of code .
C#using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
static class Program
{
private static String updaterModulePath;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
#if DEBUG
#else
// Start the thread that will launch the updater in silent mode with 10 second delay.
Thread thread = new Thread(new ThreadStart(StartSilent));
thread.Start();
// Compute the updater.exe path relative to the application main module path
updaterModulePath = Path.Combine(Application.StartupPath, "updater.exe");
#endif
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
private static void StartSilent()
{
Thread.Sleep(10000);
Process process = Process.Start(updaterModulePath, "/silent");
process.Close();
}
}
}
I rather like the CodeCleanup feature but it exhibits some undesirable effects on a file like this. Attached is muy settings files. The problem seems to be with remove unused members, remove unused namespace references, remove unused private types and remove unused types.
If you add for arguments sake a single property to the code above and then invoke save the code designed to run only and runtime in release configuration will be rendered unusable. I know why but I can't figure out how to stop it happening. The same goes if I temporarily comment out some code to experiment with different refactoring's. Various bits that it used will be removed.
Typically when I am pretty certain that I have finished working in a file I will invoke organize members to tidy things up, that's the point at which one really wants most of the cleanup to occur, so How can I retain the cleanup options that I have, retain code formatting particularly on each save and avoid having code that is specifically designed to run at runtime and in release mode only broken in the cleanup process.