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# Impement virtual method changes access modifier
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

xMRi
Tomato Guru

Germany
315 Posts

Posted - Mar 26 2018 :  08:16:29 AM  Show Profile  Reply with Quote
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

Martin Richter [rMVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming

feline
Whole Tomato Software

United Kingdom
18988 Posts

Posted - Mar 26 2018 :  10:56:49 AM  Show Profile  Reply with Quote
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.

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

xMRi
Tomato Guru

Germany
315 Posts

Posted - Mar 27 2018 :  02:20:30 AM  Show Profile  Reply with Quote
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:


Martin Richter [rMVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming

Edited by - xMRi on Mar 27 2018 02:45:03 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18988 Posts

Posted - Mar 27 2018 :  08:57:45 AM  Show Profile  Reply with Quote
Installing Xamarin now, then I shall test this situation.

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

feline
Whole Tomato Software

United Kingdom
18988 Posts

Posted - Mar 27 2018 :  1:40:36 PM  Show Profile  Reply with Quote
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.

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

xMRi
Tomato Guru

Germany
315 Posts

Posted - Mar 27 2018 :  1:53:11 PM  Show Profile  Reply with Quote
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!

Martin Richter [rMVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18988 Posts

Posted - Mar 27 2018 :  3:02:56 PM  Show Profile  Reply with Quote
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.

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

feline
Whole Tomato Software

United Kingdom
18988 Posts

Posted - Mar 28 2018 :  11:14:25 AM  Show Profile  Reply with Quote
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.

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:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000