Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VB wpfdpro snippet emits wrong code #3469

Closed
ljw1004 opened this issue Jun 12, 2015 · 4 comments
Closed

VB wpfdpro snippet emits wrong code #3469

ljw1004 opened this issue Jun 12, 2015 · 4 comments

Comments

@ljw1004
Copy link
Contributor

ljw1004 commented Jun 12, 2015

Repro:
(1) File>New>VB>Windows>Desktop>WPF application
(2) open up MainPage.xaml.vb and inside the class type wpfdpro and press TAB.

What I get: there are two errors because it's failing to pick up the name of the enclosing type. It emits GetValue(.Prop1Property) without the classname in front of the dot. And it emits GetType() because without the classname inside parentheses.

Also, stylistically, it should be using NameOf now instead of the string literal "Prop1".

wpfdpro

@Pilchie Pilchie added this to the 1.1 milestone Jun 12, 2015
@dpoeschl dpoeschl changed the title VB wpfdpro shortcut emits wrong code VB wpfdpro snippet emits wrong code Jun 12, 2015
@AdamSpeight2008
Copy link
Contributor

@ljw1004 Could you provide an example of how it should look?

@ljw1004
Copy link
Contributor Author

ljw1004 commented Jun 12, 2015

In this case it should look like this:

    Public ReadOnly Property Prop1 As String
        Get
            Return CType(GetValue(MainWindow.Prop1Property), String)
        End Get
    End Property

    Private Shared ReadOnly Prop1PropertyKey As DependencyPropertyKey =
                            DependencyProperty.RegisterReadOnly("Prop1",
                            GetType(String), GetType(MainWindow),
                            New PropertyMetadata(Nothing))

    Public Shared ReadOnly Prop1Property As DependencyProperty =
                           Prop1PropertyKey.DependencyProperty

CHANGES I EXPECT:

(1) Change GetValue(.Prop1Property) into either GetValue(MainWindow.Prop1Property) or GetValue(Prop1Property). The latter would be nicer.

(2) Change GetType() into GetType(MainWindow).

(3) Add the necessary CStr or CType to the property getter.

@dpoeschl
Copy link
Contributor

dpoeschl commented Sep 1, 2015

Some notes:

It emits GetValue(.Prop1Property) without the classname in front of the dot.

This is because the current authoring has the literal defined as ownertype but the references are listed as ownerType. This casing difference probably didn't matter in the old VB snippets implementation, but the merged implementation (the same one used by C# pre-VS2015) takes casing into account.

However, even then, it will just default to Window1 instead of your actual surrounding class, because it wasn't using the ClassName() snippet function.

Also, stylistically, it should be using NameOf now instead of the string literal "Prop1".

For things like that, I think we should go through and update all of the existing snippets, rather than just updating individuals as they are noticed.

@Pilchie Pilchie modified the milestones: 1.1(preview), 1.1, 1.2 Sep 9, 2015
@dpoeschl dpoeschl modified the milestones: 1.3, 1.2 Feb 1, 2016
@dpoeschl dpoeschl modified the milestones: Unknown, 1.3 Mar 30, 2016
@dpoeschl dpoeschl removed their assignment Jun 10, 2020
@CyrusNajmabadi
Copy link
Member

CLosing out as we are not investing in these legacy snippets.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2024
@dotnet dotnet locked and limited conversation to collaborators Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants