Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Generate virtual method without 'virtual' keyword

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
Alexey.Malov Posted - Jun 09 2017 : 4:57:53 PM
In our code base we use the following recommendation from c++ core guidelines:
'C.128: Virtual functions should specify exactly one of virtual, override, or final'
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-override


class ISomeInterface
{
public:
    virtual ~ISomeInterface() = default;
    virtual void Food() = 0;
};

class SomeClass : public ISomeInterface
{
public:
    void Foo()override; // no need to add 'virtual' since 'override' can be applied to virtual methods only
};


Currently, Visual Assist adds both 'virtual' and 'override' options when implementing virtual method, so we have to remove 'virtual' keyword manually for each auto-generated method.

It would be great if there was an option to generate virtual method without 'virtual' keyword (only with override).
5   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Mar 13 2018 : 3:57:36 PM
This is relatively low priority, but it is now being looked at, and we hope to add this in the next few builds of VA.

As always, it is a case of balancing bug fixes with new features and other changes. Never an easy task.
MrDoomMaster Posted - Mar 13 2018 : 10:09:26 AM
I'd like to bump this since it's been a year and I also would love the ability to turn off 'virtual' keyword when implementing base class virtual methods through the refactoring menu. Any updates on progress this past year? This seems like a relatively simple addition. Is it just a low priority and that is why it hasn't been done yet?
feline Posted - Jun 13 2017 : 09:15:32 AM
Apologies for the confusion, the registry key is for the new Code Inspection features, not the older refactoring command. We are considering adding a setting to leave off the virtual keyword when the override keyword is being used:

case=85265

which I think is what you are looking for here. Unfortunately there is no way to do this automatically yet.
Alexey.Malov Posted - Jun 13 2017 : 05:54:58 AM
Hmm. It seems that we are talking about different things. At least, this option does not affect the behavior of 'Implement Virtual Methods' refactoring function.

I was talking about the behavior of "Implement Virtual Methods..." refactoring option.

When I have an interface

class ISomeInterface
{
public:
    virtual ~ISomeInterface() = default;
    virtual void Food() = 0;
};

and want to implement its methods in a some class:

class SomeClass : public ISomeInterface
{
public:

};

I right click on the class name and choose Quick Actions and Refactorings (VA)->Implement Virtual Methods. What I want is to generate virtual methods without virtual keyword (leaving only override). This would simplify to use one coding style without need to manually remove 'virtual' from auto-generated code.
holedigger Posted - Jun 10 2017 : 02:14:28 AM
Good news, there is an option for this, but we haven't exposed UI for it yet, so you'll need to edit the registry.

Close all instances of Visual Studio, then use regedit to find key:
HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VANet{IDE_VER}\CodeInspections

The default value for CheckerOptions is "modernize-use-override.VirtualHandling=insert"

Change "insert" to "remove", and you should get the behavior you're looking for. There are three options:
"insert" = add virtual if not present
"remove" = remove virtual if present
"keep" = don't add it, but don't remove it either

Personally, I like having both 'virtual' and 'override', but the Core Guidelines do say to remove the virtual, so we'll probably change the default to "remove".

Note: these registry settings will be changing in upcoming builds, but not before we add UI to change them in our options dialog.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000