Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 C# Impement virtual method changes access modifier

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
xMRi Posted - Mar 26 2018 : 08:16:29 AM
There is a the following signature in one of the base classes:

protected override bool OnBackButtonPressed();


Now I am in a derived class and call the command "Implement virtual methods".
I choose this one function.

The inserted code is wrong:
public override bool OnBackButtonPressed()
        {
            throw new NotImplementedException();
        }


The function signature must be protected
7   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Mar 28 2018 : 11:14:25 AM
I am not sure what's going on here, there doesn't appear to be anything in the code that is tripping VA up, VA just seems to believe that all members of all Xamarin base classes are public, which is clearly wrong. I have put in a bug report for this:

case=115414

In the cases where VA understands if a function is public or protected, the function is being generated with the matching, and correct, access for me.
feline Posted - Mar 27 2018 : 3:02:56 PM
My mistake, I got turned around somewhere, and thought that the method VA was generating was supposed to be public, and you were seeing it as protected. I see the problem now, now trying to see if I can find what triggers this problem.
xMRi Posted - Mar 27 2018 : 1:53:11 PM
And this is wrong. The access modifier must never change. This causes a warning in C#.

The base class marks this method as protected! And VAX creates it as public!
feline Posted - Mar 27 2018 : 1:40:36 PM
Well that took longer than expected, but I still cannot reproduce this problem.

Since I wasn't able to get VA to offer a full list of methods most of the time in a new default Xamarin Forms project, probably because I was not setting things up right, I have downloaded and extracted the sample project from this page:

https://developer.xamarin.com/samples/xamarin-forms/Navigation/TabbedPage/

which I have opened in VS2017. In the "TabbedPageDemo (Portable)" project I have opened the file "TabbedPageDemoPageCS.cs"

This already contains a class derived from TabbedPage, so its a good test file. I have added your test class, so the top of my file now reads:

using Xamarin.Forms;

namespace TabbedPageDemo
{
    public class FooPage : TabbedPage
    { 
    }

trigger Implement Virtual Methods on FooPage lists quite a few base classes. I have collapsed all of the open nodes, and made sure every parent node is unchecked. Then I expanded just the single node "MultiPage<Xamarin.Forms.Page>", which seems to be the same base class you are using, and selected the OnBackButtonPressed() function. VA then generates:
        public override bool OnBackButtonPressed()
        {
            throw new NotImplementedException();
        }

Can you please try the same test? I am wondering if I have somehow missed some key step here, or if your problem is somehow solution or even file specific?

VS2017 is version 15.6.4, and Xamarin was installed today, so should also be fully up to date.
feline Posted - Mar 27 2018 : 08:57:45 AM
Installing Xamarin now, then I shall test this situation.
xMRi Posted - Mar 27 2018 : 02:20:30 AM
I can repro this all the time. In detail:

1. I have a Xamarin project.
2. a simple class
public class FooPage : TabbedPage

3. I try to implement
protected override bool OnBackButtonPressed();

From class
MultiPage<Page>

I am using:
VA_X.dll file version 10.9.2258.5 built 2018.03.06
DevEnv.exe version 15.6.27428.2011 Enterprise
msenv.dll version 15.0.27428.2011
Comctl32.dll version 6.10.16299.309
Windows 10 10.0 Build 16299
8 processors (x86-64, WOW64)
Language info: 1252, 0x407

Platform: Project defined
Stable Includes:

Other Includes:

Stable Source Directories:

feline Posted - Mar 26 2018 : 10:56:49 AM
So far I cannot reproduce this problem, for me a protected member in the base class is always becoming a protected member in the derived class. This is with VS2017 and VA 2258.

Which IDE and version of VA are you using?

If you delete this incorrect function and repeat the test, do you get the same problem? I am wondering if this is reliable, or somehow random? I would expect it to be reliable, but want to check that assumption.

Also, how are you triggering this command? That should not matter, but its another variable to consider.

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