Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 C# Implement Virtual Methods oddities
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nitz
Junior Member

11 Posts

Posted - Aug 01 2019 :  11:36:19 AM  Show Profile  Reply with Quote
Hello!

I've recently been doing a lot of work in C# and have run into some funny things with the way "Implement Virtual Methods" seems to be working in C# currently.

First, it sometimes seems to incorrectly change method access modifiers. Searching the forms it seems someone has brought this up (case=115414), but I'm seeing it in winforms things without Xamarin.

As an example: Inheriting from System.Windows.Forms.Design.ControlDesigner, and overriding PreFilterProperties(): https://i.imgur.com/MABo8WY.png

Results in: https://i.imgur.com/TdoLA6d.png -- with a public access modifier, despite needing to be `protected`.

It's worth mentioning that the method `PreFilterProperties()` is initially defined by `IDesignerFilter`, which obviously does not specify access modifiers, where as the class up the tree `ComponentDesigner` does declare it protected. Perhaps that's some part of what's causing the issue?

--

My second issue with Implement Virtual Methods is that for some classes, a slew of methods come pre-checked despite not needing to be.

An example for this is overriding a UserControl. The first time I open "Implement Virtual Methods" and just hit okay without doing anything, it adds nearly 50 methods! And Doing it again adds even more! I feel like by default it shouldn't have anything checked and I should be able to tick just the ones I want (unless there are any abstract methods that aren't implemented, or interface methods not defined -- those could come checked.) But in the case of UserControl, everything is satisfied already (`class M : UserControl{}` complies just fine)

Thanks for the help!

--

Info:
VA_X.dll file version 10.9.2341.0 built 2019.07.11
DevEnv.exe version 16.1.29102.190 Community
msenv.dll version 16.0.29020.237
Comctl32.dll version 6.10.18362.239
Windows 10 10.0 1903 Build 18362.239
8 processors (x86-64, WOW64)
Language info: 1252, 0x409

accord
Whole Tomato Software

United Kingdom
3195 Posts

Posted - Aug 02 2019 :  04:23:17 AM  Show Profile  Reply with Quote
I was able to reproduce your first problem:

case=141044

Thank you for the clear description and the tip about why it fails.
I'll look into your second problem as well.
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3195 Posts

Posted - Aug 02 2019 :  2:02:12 PM  Show Profile  Reply with Quote
I wasn't completely able to reproduce your second problem. When I run Implement Virtual Methods on your example, I only get ActivateControl ticked.
Can you please create a clean new C# Windows Forms App project and paste the below code to the bottom of Form1.cs and run Implement Virtual Method on it to see if you get a different result?

class M : UserControl
{
}


I'm using Visual Studio 2019 and Visual Assist 2341.

Since your sample code compiles without adding anything, I think that adding ActivateControl is already unnecessary by default. I have put in a bug report for that:

case=141050
Go to Top of Page

nitz
Junior Member

11 Posts

Posted - Aug 05 2019 :  07:26:46 AM  Show Profile  Reply with Quote
I updated my visual studio to the lastest non-prerelease (16.2) and gave it a shot too, still seeing it pasted below Form1 in Form1.cs. Here's a short video clip of what I'm seeing: https://i.imgur.com/8rfQP97.gifv

In particular, the ones that seem checked are all marked abstract (despite must have been overridden somewhere else up the inheritance tree.) It also doesn't seem to be whole objects either. For example: https://i.imgur.com/NDLVBMJ.png IPersistStreamInit there has GetClassID grey'd out, InitNew *unchecked*, but the rest checked? I'm not seeing any rhyme or reason to it directly.

I don't think any of the other extensions I have installed should be conflicting in a way like this, but I can provide a list if you'd think that may be part of it too.

Thanks for all the help!

-- Updated version info:
VA_X.dll file version 10.9.2341.0 built 2019.07.11
DevEnv.exe version 16.2.29123.88 Community
msenv.dll version 16.0.29122.156
Comctl32.dll version 6.10.18362.239
Windows 10 10.0 1903 Build 18362.239
8 processors (x86-64, WOW64)
Language info: 1252, 0x409
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3195 Posts

Posted - Aug 05 2019 :  4:44:19 PM  Show Profile  Reply with Quote
This is interesting. I'm not sure what is causing the difference. I'm not familiar with C#, so as a wild guess maybe a different version of .net framework or windows 10 build? I'm using Win10 1903 and .Net Framework 4.8.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16050 Posts

Posted - Aug 06 2019 :  07:54:23 AM  Show Profile  Reply with Quote
I have reproduced the problem here, now I just want to try and understand why it is happening in one project, but not another. I am seeing this in a newly created C# Forms application, which defaulted to using .NET Framework 4.7.2 when I created it. So it is possible the targeted version of .NET is the key factor here.

zen is the art of being at one with the two'ness
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16050 Posts

Posted - Aug 06 2019 :  08:34:56 AM  Show Profile  Reply with Quote
Can you please try rebuilding your VA symbol database, via:

VA Options -> Performance -> Rebuild symbol databases

this will require an IDE restart, but should only take a couple of minutes. After doing this I cannot reproduce the problem here any more. So I am wondering if it will have the same effect on your system.

zen is the art of being at one with the two'ness
Go to Top of Page

nitz
Junior Member

11 Posts

Posted - Aug 06 2019 :  10:12:03 AM  Show Profile  Reply with Quote
My default project settings did target .NET Framework 4.7.2.

Rebuilding the symbol database, and re-opening the same project, I see the same behavior accord saw in case=141050, ActivateControl was checked by default and shouldn't have been. Other than that, none of the tons of others seemed to be!

I'm not sure what I did to manage to get it into the state where the symbol database was wonky like that, but resetting it seemed to nearly do the trick, feline! Excellent!
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3195 Posts

Posted - Aug 06 2019 :  11:27:37 AM  Show Profile  Reply with Quote
Thanks guys for the help.
I've checked what my test project is targeting and it is the same: .NET Framework 4.7.2.
But I do have .NET 4.8 installed. If

Tools -> General -> Optimize rendering for screens with different pixel densities (requires restart)

is NOT grayed out, it mean 4.8 is installed.

But I don't think this is a factor. I hope this was a one-off problem. Not sure if it is. But fixing the problem what is always reproducible would be a good start and may fix the occasional other items as well.

Edited by - accord on Aug 06 2019 11:28:49 AM
Go to Top of Page

nitz
Junior Member

11 Posts

Posted - Aug 06 2019 :  11:40:50 AM  Show Profile  Reply with Quote
Interesting. I can't even target .NET 4.8 (https://i.imgur.com/cAqeXWi.png), but I sure have that option not grayed out (https://i.imgur.com/3CQHcdh.png). .NET 4.8 isn't available through the VS Installer yet afaik, and I don't think I've installed the targeting pack/sdk separately.

I'm trying to retrace my steps of how I might have gotten the symbol db in a funky state. I've been maintaining installs of both Visual Studio 2019 and 2017 for a while, and though I removed 2017 recently. Perhaps something funny due to shared symbol dbs between them? (the VS2017 was several patches behind and didn't have nearly the amount of targeting and such I had installed for 2019.)

I really appreciate y'alls help! :)
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
16050 Posts

Posted - Aug 06 2019 :  11:56:25 AM  Show Profile  Reply with Quote
I have also tried a couple of things myself to try and get back to a state where I can see the problem here. A rather wild guess is that jumping between projects using / targeting different versions of .NET can cause VA's symbol database to collect information on more than one version of .NET at a time, and that somehow this is a factor. But if so, I cannot reproduce this quickly and easily.

So hopefully this is something of a one off problem for you.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2019 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000