Extender Provider code generation bug

G

Guest

Hi!

I think I've found a bug in the way code gets generated for an extender
provider property.
My extender provider is to provide a control to another control, that, when
clicked, will pop up a FolderBrowser and set the first control's text to the
selected folder.
Basically this means bringing textboxes and buttons together by defining
which button to click to select a path displayed in a text box.
That's my ProvidePropertyAttribute:
[ProvideProperty("BrowseButton", typeof(Control))]

Everything works OK as long as extendee and BrowseButton (the property
provided) aren't the same object.

When I try to set a control to be its own BrowseButton (in this example, a
linkLabel), I get this bad code generated:

this.folderBrowserExtenderProvider1.SetBrowseButton(this.linkLabel1,
this.folderBrowserExtenderProvider1.SetBrowseButton);

instead of

this.folderBrowserExtenderProvider1.SetBrowseButton(this.linkLabel1,
this.linkLabel1);

When I add the correct call to SetBrowseButton() to code manually,
everything works as expected, but selecting the control in the designer
always produces the bogus code above.

Can anybody help? What can I do?

Thanks in advance,
Martin Müller
 
J

Jeffrey Tan[MSFT]

Hi Martin,

Thanks for your posting!

Based on my understanding, you implemented a IExtenderProvider, which add a
"BrowseButton" property to other controls on the form. But when you set the
extended property for a control of the same type as the provided property,
you find that the VS.net designer will generate incorrect code for it.

I am not sure of how you implement the "BrowseButton" class and
SetBrowseButton/GetBrowseButton methods, can you paste some code snippet or
a sample project for me to reproduce out this issue? Then, I can help you
better. Thanks. I will wait for your further feedback.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

Dear Jeffrey,
thanks for your interest.

Here's the code for one of the extenders that shows the problem:

[ProvideProperty("BrowseButton", typeof(Control))]
public class FolderBrowserExtenderProvider : Component, IExtenderProvider
{
private Hashtable extendees;
protected FolderBrowserDialog folderDialog;

public FolderBrowserExtenderProvider()
{
extendees = new Hashtable();
folderDialog = new FolderBrowserDialog();
}

[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public System.Windows.Forms.FolderBrowserDialog FolderBrowserDialog
{
get { return folderDialog; }
}

public bool CanExtend(object extendee)
{
return (extendee is Control);
}

[DefaultValue(null)]
public Control GetBrowseButton(Control extendee)
{
if (extendees.Contains(extendee))
return (Control)extendees[extendee];
else
return null;
}

public void SetBrowseButton(Control extendee, Control browseButton)
{
if (extendees.Contains(extendee))
{
Control btn = extendees[extendee] as Control;
btn.Click -= new EventHandler(browseButton_Click);
extendees.Remove(extendee);
}
if (browseButton == null)
return;

extendees[extendee] = browseButton;
browseButton.Click += new EventHandler(browseButton_Click);
}

// browseButton_Click omitted for shortness
}
-------------------------
Hope you can reproduce the behaviour.
It only occurrs when you try to assign a control to be its own BrowseButton
via the VS designer.

Regards,
Martin Müller
 
J

Jeffrey Tan[MSFT]

Hi Martin,

Thanks very much for your feedback!!

Yes, with your code snippet, I have reproduced out your issue. I will spend
some more time on this issue to do some research. I will reply to you ASAP.
Thanks for your understanding!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Martin,

Sorry for letting you wait for so long.

I have created a sample reproduce project and help you to feedback it to
our product team, and our product team may review this issue.

Also, you may provide your own suggestion for this issue to
"http://register.microsoft.com/mswish/suggestion.asp".

If you still have much concern on this issue, and is urgent on it, please
feel free to tell me, I will provide you the way to contact our PSS. The
PSS may help you to obtain a hotfix for it.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

Dear Jeffrey,

thanks for propagating the case to the product team.

Do you know of any workarounds?
Right now I'm throwing an exception when i'm at design time and trying to
assign a control to be it's own extender, but that's not really elegant.

Any ideas?

Thanks,
Martin Müller
 
J

Jeffrey Tan[MSFT]

Hi Martin,

Thanks for your feedback!

Yes, I have already tried to find a workaround for you, but since there is
little thing we can do to the Code generation in VS.net design-time, I
still can not find a workaround for this issue. So I say that if this issue
has much impact on your business, you may contact PSS to request a hotfix.
Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Ok, if you need further help, please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top