[326] Suggest parameter of type

Hi

How is the Suggest Parameter of Type live template macro supposed to work?

As far as I understand, it should suggest a method parameter of the given
type.

However if I specify the type as System.String, it suggests "string" instead
of a parameter name.

Example:

I expected:

public void MyMethod(string name) {
if (string.IsNullOrEmpty(name)) {
}
}

But I get:

public void MyMethod(string name) {
if (string.IsNullOrEmpty(string)) {
}
}


Best regards
Jakob Christensen


5 comments
Comment actions Permalink

Hello,

We appreciate your feedback.

The corresponding JIRA request has been created, and you are welcome to monitor
its status at http://www.jetbrains.net/jira/browse/RSRP-33282.

Best regards,
- Development Team.


0
Comment actions Permalink

Hello Jakob,

Could you please export template you created and attach it to this issue?
I cannot reproduce the problem.

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


JC> Hi
JC>
JC> How is the Suggest Parameter of Type live template macro supposed to
JC> work?
JC>
JC> As far as I understand, it should suggest a method parameter of the
JC> given type.
JC>
JC> However if I specify the type as System.String, it suggests "string"
JC> instead of a parameter name.
JC>
JC> Example:
JC>
JC> I expected:
JC>
JC> public void MyMethod(string name) {
JC> if (string.IsNullOrEmpty(name)) {
JC> }
JC> }
JC> But I get:
JC>
JC> public void MyMethod(string name) {
JC> if (string.IsNullOrEmpty(string)) {
JC> }
JC> }
JC> Best regards
JC> Jakob Christensen


0
Comment actions Permalink

Hi Ilya

Here you go:

]]>


I have attached a screenshot of what happens when I expand the template.

Thanks
--Jakob


Hello Ilya,

Hello Jakob,

>

Could you please export template you created and attach it to this
issue? I cannot reproduce the problem.

>

Sincerely,
Ilya Ryzhenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

JC>> Hi
JC>>
JC>> How is the Suggest Parameter of Type live template macro supposed
JC>> to work?
JC>>
JC>> As far as I understand, it should suggest a method parameter of the
JC>> given type.
JC>>
JC>> However if I specify the type as System.String, it suggests
JC>> "string" instead of a parameter name.
JC>>
JC>> Example:
JC>>
JC>> I expected:
JC>>
JC>> public void MyMethod(string name) {
JC>> if (string.IsNullOrEmpty(name)) {
JC>> }
JC>> }
JC>> But I get:
JC>> public void MyMethod(string name) {
JC>> if (string.IsNullOrEmpty(string)) {
JC>> }
JC>> }
JC>> Best regards
JC>> Jakob Christensen

Attachment not added (general error): "livetemplate.png"

0
Comment actions Permalink

Hello Jakob,

Thank you, I was able to reproduce the problem. It will be fixed in the nearest
bugfix update.
Unfortunately I was not able to come up with a workaround.

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


JC> Hi Ilya
JC>
JC> Here you go:
JC>
JC> JC> JC> text="Assert.ArgumentNotNullOrEmpty($var$, "$var$");" JC> shortcut="as" description="Assert a string argument" reformat="true" JC> shortenQualifiedReferences="true"> JC> JC> expression="parameterOfType("System.String")" JC> initialRange="0" /> JC> JC> JC> JC> JC> JC> I have attached a screenshot of what happens when I expand the JC> template. JC> JC> Thanks JC> --Jakob JC> Hello Ilya, JC> >> Hello Jakob, >> >> Could you please export template you created and attach it to this >> issue? I cannot reproduce the problem. >> >> Sincerely, >> Ilya Ryzhenkov >> JetBrains, Inc >> http://www.jetbrains.com >> "Develop with pleasure!" JC>>> Hi JC>>> JC>>> How is the Suggest Parameter of Type live template macro supposed JC>>> to work? JC>>> JC>>> As far as I understand, it should suggest a method parameter of JC>>> the given type. JC>>> JC>>> However if I specify the type as System.String, it suggests JC>>> "string" instead of a parameter name. JC>>> JC>>> Example: JC>>> JC>>> I expected: JC>>> JC>>> public void MyMethod(string name) { JC>>>]]> if (string.IsNullOrEmpty(name)) {
JC>>> }
JC>>> }
JC>>> But I get:
JC>>> public void MyMethod(string name) {
JC>>> if (string.IsNullOrEmpty(string)) {
JC>>> }
JC>>> }
JC>>> Best regards
JC>>> Jakob Christensen


0
Comment actions Permalink

Hi Ilya

Great - we have changed the macro to Execute Smart Completion, which works
almost as well.

--Jakob


Hello Ilya,

Hello Jakob,

Thank you, I was able to reproduce the problem. It will be fixed in
the nearest
bugfix update.
Unfortunately I was not able to come up with a workaround.
Sincerely,
Ilya Ryzhenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

JC>> Hi Ilya
JC>>
JC>> Here you go:
JC>>
JC>> JC>> JC>> > text="Assert.ArgumentNotNullOrEmpty($var$, "$var$");" JC>> shortcut="as" description="Assert a string argument" JC>> reformat="true" JC>> shortenQualifiedReferences="true"> JC>> JC>> > expression="parameterOfType("System.String")" JC>> initialRange="0" /> JC>> JC>> JC>> JC>> JC>> JC>> I have attached a screenshot of what happens when I expand the JC>> template. JC>> Thanks JC>> --Jakob JC>> Hello Ilya, >>> Hello Jakob, >>> >>> Could you please export template you created and attach it to this >>> issue? I cannot reproduce the problem. >>> >>> Sincerely, >>> Ilya Ryzhenkov >>> JetBrains, Inc >>> http://www.jetbrains.com >>> "Develop with pleasure!" JC>>>> Hi JC>>>> JC>>>> How is the Suggest Parameter of Type live template macro supposed JC>>>> to work? JC>>>> JC>>>> As far as I understand, it should suggest a method parameter of JC>>>> the given type. JC>>>> JC>>>> However if I specify the type as System.String, it suggests JC>>>> "string" instead of a parameter name. JC>>>> JC>>>> Example: JC>>>> JC>>>> I expected: JC>>>> JC>>>> public void MyMethod(string name) { JC>>>>]]> if (string.IsNullOrEmpty(name)) {
JC>>>> }
JC>>>> }
JC>>>> But I get:
JC>>>> public void MyMethod(string name) {
JC>>>> if (string.IsNullOrEmpty(string)) {
JC>>>> }
JC>>>> }
JC>>>> Best regards
JC>>>> Jakob Christensen


0

Please sign in to leave a comment.