Make your damn mind up Visual Studio!
-
OK, VS2019 is installed, and I loaded a small test project into it - the one I use for checking code before I answer a QA question, as it happens. And the first thing I notice (once I've got all the windows where they belong, and found where to turn off the line numbers anyway) is that it "suggests" changes: using an expression bodied constructor instead of the older style:
public frmMain()
{
InitializeComponent();
}IS out, and this is in:
public frmMain() => InitializeComponent();
Hmmm ... OK, I can learn to live with that. Then: "Replace GetWindowsInstallationDateTime with a property":
public static DateTime GetWindowsInstallationDateTime() { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; }
Is out, this is in:
public static DateTime WindowsInstallationDateTime { get { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; } }
Hmmm. Less sure about this, but I can see why. Kinda. OK. Do it. What's next? Oh, right: "Replace WindowsInstallationDateTime with a method". Hang on a moment ... you want to replace
public static DateTime WindowsInstallationDateTime { get
AI at it's greatest!!!
"The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge". Stephen Hawking, 1942- 2018
-
Depends: if the first one is rubbish, then no. If the first one is good, I'll probably try the second. But this is more like the waiter recommending you ignore the menu and go from the specials board, then when he comes back to take the order telling you the specials aren't as good as the regular menu ... :laugh:
Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
OriginalGriff wrote:
But this is more like the waiter recommending you ignore the menu and go from the specials board, then when he comes back to take the order telling you the specials aren't as good as the regular menu ... :laugh:
If you accept each suggestion, than you will be eathing the special, and after finishing and adding it to the total, you'll be suggested to eat from the regular menu. Just like there's tools to "extract" a variable to a property, and back.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
AI at it's greatest!!!
"The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge". Stephen Hawking, 1942- 2018
AS at it's greatest.
-
OK, VS2019 is installed, and I loaded a small test project into it - the one I use for checking code before I answer a QA question, as it happens. And the first thing I notice (once I've got all the windows where they belong, and found where to turn off the line numbers anyway) is that it "suggests" changes: using an expression bodied constructor instead of the older style:
public frmMain()
{
InitializeComponent();
}IS out, and this is in:
public frmMain() => InitializeComponent();
Hmmm ... OK, I can learn to live with that. Then: "Replace GetWindowsInstallationDateTime with a property":
public static DateTime GetWindowsInstallationDateTime() { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; }
Is out, this is in:
public static DateTime WindowsInstallationDateTime { get { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; } }
Hmmm. Less sure about this, but I can see why. Kinda. OK. Do it. What's next? Oh, right: "Replace WindowsInstallationDateTime with a method". Hang on a moment ... you want to replace
public static DateTime WindowsInstallationDateTime { get
Microsoft, putting the artificial in intelligence.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
OK, VS2019 is installed, and I loaded a small test project into it - the one I use for checking code before I answer a QA question, as it happens. And the first thing I notice (once I've got all the windows where they belong, and found where to turn off the line numbers anyway) is that it "suggests" changes: using an expression bodied constructor instead of the older style:
public frmMain()
{
InitializeComponent();
}IS out, and this is in:
public frmMain() => InitializeComponent();
Hmmm ... OK, I can learn to live with that. Then: "Replace GetWindowsInstallationDateTime with a property":
public static DateTime GetWindowsInstallationDateTime() { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; }
Is out, this is in:
public static DateTime WindowsInstallationDateTime { get { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; } }
Hmmm. Less sure about this, but I can see why. Kinda. OK. Do it. What's next? Oh, right: "Replace WindowsInstallationDateTime with a method". Hang on a moment ... you want to replace
public static DateTime WindowsInstallationDateTime { get
-
AI at it's greatest!!!
"The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge". Stephen Hawking, 1942- 2018
-
OK, VS2019 is installed, and I loaded a small test project into it - the one I use for checking code before I answer a QA question, as it happens. And the first thing I notice (once I've got all the windows where they belong, and found where to turn off the line numbers anyway) is that it "suggests" changes: using an expression bodied constructor instead of the older style:
public frmMain()
{
InitializeComponent();
}IS out, and this is in:
public frmMain() => InitializeComponent();
Hmmm ... OK, I can learn to live with that. Then: "Replace GetWindowsInstallationDateTime with a property":
public static DateTime GetWindowsInstallationDateTime() { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; }
Is out, this is in:
public static DateTime WindowsInstallationDateTime { get { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; } }
Hmmm. Less sure about this, but I can see why. Kinda. OK. Do it. What's next? Oh, right: "Replace WindowsInstallationDateTime with a method". Hang on a moment ... you want to replace
public static DateTime WindowsInstallationDateTime { get
Visual Studio doesn’t tell you what to do: it offers suggestions. “Would you like to shoot yourself in the foot or hang yourself with too much rope” It just likes to feel helpful in these big life altering decisions.
cheers Chris Maunder
-
Visual Studio doesn’t tell you what to do: it offers suggestions. “Would you like to shoot yourself in the foot or hang yourself with too much rope” It just likes to feel helpful in these big life altering decisions.
cheers Chris Maunder
Chris Maunder wrote:
Visual Studio doesn’t tell you what to do: it offers suggestions. “Would you like to shoot yourself in the foot or hang yourself with too much rope” It just likes to feel helpful in these big life altering decisions.
SO if I'm reading this correctly, you're saying that Visual Studio is the new Clippy.
Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004
-
Chris Maunder wrote:
Visual Studio doesn’t tell you what to do: it offers suggestions. “Would you like to shoot yourself in the foot or hang yourself with too much rope” It just likes to feel helpful in these big life altering decisions.
SO if I'm reading this correctly, you're saying that Visual Studio is the new Clippy.
Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004
:thumbsup: I may have a brief couple of hours lay-over in Sydney next month. You around?
cheers Chris Maunder
-
OK, VS2019 is installed, and I loaded a small test project into it - the one I use for checking code before I answer a QA question, as it happens. And the first thing I notice (once I've got all the windows where they belong, and found where to turn off the line numbers anyway) is that it "suggests" changes: using an expression bodied constructor instead of the older style:
public frmMain()
{
InitializeComponent();
}IS out, and this is in:
public frmMain() => InitializeComponent();
Hmmm ... OK, I can learn to live with that. Then: "Replace GetWindowsInstallationDateTime with a property":
public static DateTime GetWindowsInstallationDateTime() { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; }
Is out, this is in:
public static DateTime WindowsInstallationDateTime { get { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; } }
Hmmm. Less sure about this, but I can see why. Kinda. OK. Do it. What's next? Oh, right: "Replace WindowsInstallationDateTime with a method". Hang on a moment ... you want to replace
public static DateTime WindowsInstallationDateTime { get
Admittedly off-topic, but wouldn't you want to cache the value (if any) read from the registry? /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Chris Maunder wrote:
Visual Studio doesn’t tell you what to do: it offers suggestions. “Would you like to shoot yourself in the foot or hang yourself with too much rope” It just likes to feel helpful in these big life altering decisions.
SO if I'm reading this correctly, you're saying that Visual Studio is the new Clippy.
Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004
VS2019 has AI in its intellisense. No, really. (See the VS2019 keynote.) /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
:thumbsup: I may have a brief couple of hours lay-over in Sydney next month. You around?
cheers Chris Maunder
Chris Maunder wrote:
I may have a brief couple of hours lay-over in Sydney next month. You around?
Now just so you understand, I have read this as I only have a couple of hours to drink sometime next month. You set the pace and I will try and keep up. So yes, I am around.
Michael Martin Australia "I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible." - Mr.Prakash One Fine Saturday. 24/04/2004
-
Admittedly off-topic, but wouldn't you want to cache the value (if any) read from the registry? /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
For anything other than "when was Windows installed?" probably yes - but how many times does an app need to know that? :laugh: It was a response to a very specific question!
Sent from my Amstrad PC 1640 Never throw anything away, Griff Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
-
OK, VS2019 is installed, and I loaded a small test project into it - the one I use for checking code before I answer a QA question, as it happens. And the first thing I notice (once I've got all the windows where they belong, and found where to turn off the line numbers anyway) is that it "suggests" changes: using an expression bodied constructor instead of the older style:
public frmMain()
{
InitializeComponent();
}IS out, and this is in:
public frmMain() => InitializeComponent();
Hmmm ... OK, I can learn to live with that. Then: "Replace GetWindowsInstallationDateTime with a property":
public static DateTime GetWindowsInstallationDateTime() { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; }
Is out, this is in:
public static DateTime WindowsInstallationDateTime { get { Microsoft.Win32.RegistryKey key = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); key = key.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", false); if (key != null) { DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); Int64 regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()); DateTime installDate = startDate.AddSeconds(regVal); return installDate; } return DateTime.MinValue; } }
Hmmm. Less sure about this, but I can see why. Kinda. OK. Do it. What's next? Oh, right: "Replace WindowsInstallationDateTime with a method". Hang on a moment ... you want to replace
public static DateTime WindowsInstallationDateTime { get