Bug 16108 - Convert to autoproperty issues
Summary: Convert to autoproperty issues
Status: VERIFIED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: C# Binding ()
Version: unspecified
Hardware: PC Windows
: Normal normal
Target Milestone: master
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2013-11-11 08:19 UTC by Marius Ungureanu
Modified: 2014-03-27 10:57 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Marius Ungureanu 2013-11-11 08:19:59 UTC
Test case:

class MyClass
{
	[DebuggerHiddenAttribute]
	int a = 4;
	int A {
		get { return a; }
		set { a = value; }
	}
}

Expected result:

class MyClass
{
	[DebuggerHiddenAttribute]
	int A {
		get;
		set;
	}

	public MyClass () // Should be protected for abstract.
	{
		A = 4;
	}
}

Actual result:
class MyClass
{
	[DebuggerHiddenAttribute]
	int A {
		get;
		set;
	}
}


In this example, we have two issues with converting to autoproperty code action.

First, it doesn't move the initialization to the constructor. In this case, we have no constructor, so we should generate one.

Secondly, it doesn't move the attribute to the property.

When we do not have a constructor, generate a default one using default visibility. Public for non-abstract, protected for abstract.
Comment 1 Mike Krüger 2013-11-11 09:52:39 UTC
fixed.

(btw. in that case it's not convertible - changing attributes changes the semantic)
Comment 2 Sadik Ali 2014-03-27 09:56:22 UTC
I have verified this issue followed below steps:

1. Created a console project.
2. added below code mentioned in bug description.

class MyClass
{    
    int a = 4;

    int A {
        get { return a; }
        set { a = value; }
    }
}

Screen cast: http://screencast.com/t/LhfFSn1rNWeF

=== Xamarin Studio ===
Version 4.2.4 (build 266)
Installation UUID: 7d8bffd7-8a54-400c-a17e-c187f24b5eb3
Runtime:
 Microsoft .NET 4.0.30319.34003
 GTK+ 2.24.22 (MS-Windows theme)
 GTK# 2.12.25

=== Xamarin.Android ===

Version: 4.13.0 (Enterprise Edition)
Android SDK: E:\SDK\AndroidSDK
 Supported Android versions:
  2.1   (API level 7)
  2.2   (API level 8)
  2.3   (API level 10)
  3.1   (API level 12)
  3.2   (API level 13)
  4.0   (API level 14)
  4.0.3 (API level 15)
  4.1   (API level 16)
  4.2   (API level 17)
  4.3   (API level 18)
  4.4   (API level 19)
Java SDK: C:\Program Files\Java\jdk1.6.0_39
java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode)

=== Build Information ===

Release ID: 402040266
Git revision: 57fa6b7639703775ae1d5c46536e42ab424cb177
Build date: 2014-03-20 12:27:02-04
Xamarin addins: eee141c29724a19529e77b8e743086d95b29f5ba

=== Operating System ===

Windows 6.2.9200.0
Comment 3 Sadik Ali 2014-03-27 10:20:07 UTC
Please ignore the Comment #2. Comment got accidentally submitted without complete steps. 

Steps I followed describe below:

1. Created a console project.
2. added below code mentioned in bug description.

class MyClass
{    
    int a = 4;
    [DebuggerHiddenAttribute]
    int A {
        get { return a; }
        set { a = value; }
    }
}

3. I added [DebuggerHiddenAttribute] on property
4. When I tried to converting to autoproperty, I noticed that option is not displaying on property A.
5. I removed initialization of a.
6. Again I got to property A and applied converting to autoproperty feature.
7. It automation converted property as below:

class MyClass
{
    [DebuggerHiddenAttribute]
    int A {
        get;
        set;
    }
}

Please correct me if I am wrong anywhere in my understanding.

As of now, RE-OPENING this issue.

Screen cast: http://screencast.com/t/LhfFSn1rNWeF

Build Info:

=== Xamarin Studio ===
Version 4.2.4 (build 266)
Installation UUID: 7d8bffd7-8a54-400c-a17e-c187f24b5eb3
Runtime:
 Microsoft .NET 4.0.30319.34003
 GTK+ 2.24.22 (MS-Windows theme)
 GTK# 2.12.25

=== Build Information ===
Release ID: 402040266
Git revision: 57fa6b7639703775ae1d5c46536e42ab424cb177
Xamarin addins: eee141c29724a19529e77b8e743086d95b29f5ba

=== Operating System ===
Windows 6.2.9200.0
Comment 4 Mike Krüger 2014-03-27 10:53:32 UTC
Your understanding is correct & you verified it as fixed - it's not possible to generally provide a fix for that.
Comment 5 Sadik Ali 2014-03-27 10:57:57 UTC
As per comment 4 updating bug as verified