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

Any suggestion / feature request? #11

Open
ulex opened this issue Jan 15, 2015 · 31 comments
Open

Any suggestion / feature request? #11

ulex opened this issue Jan 15, 2015 · 31 comments
Labels

Comments

@ulex
Copy link
Owner

ulex commented Jan 15, 2015

Is anyone except me using ZenSharp in production environment?
Do you have any suggestion?
I'm will be very happy to any feedback.

@ulex ulex added the question label Jan 15, 2015
@adeel41
Copy link
Contributor

adeel41 commented Jan 16, 2015

It will be nice to have a editor for all rules and also if you can add alias to these rules

@Eonasdan
Copy link

how about adding DbSet short cut. I hate typing all that out.

public DbSet<T> Ts { get; set; }

aside: I'm doing a R# "magic show" talk next month, I'm going to be showcasing super cool stuff that people familiar with R# didn't know they could do. I plan to feature your plugin. Any thing that you think really shines above the rest, please let me know.

@ulex
Copy link
Owner Author

ulex commented Jul 26, 2015

@Eonasdan, DbSet is great example for ReSharper live templates, but not for ZenSharp.

Just create Live template as described here - https://www.jetbrains.com/resharper/help/Templates__Creating_and_Editing_Templates__Creating_a_Live_Template_from_Source_Code.html

@Eonasdan
Copy link

why do feel that way? ZenSharp already does property generation like that.

I tried

scope "InCSharpClass" {
  start    ::=  method | property | field | const | other

  other ::=
        //...
    | ""=dbset "public DBSet<" type " > " identifier "{get; set; }"

but I the template doesn't show a name and it doesn't generate code.

I'm trying to understand how to add custom items to your template.

@ulex
Copy link
Owner Author

ulex commented Jul 27, 2015

You're doing it right.
paizbvn 1

but I the template doesn't show a name and it doesn't generate code.

What do you mean by that ?

@Eonasdan
Copy link

ah... I see now why you said that.

ZenSharp wouldn't be able to figure out that type is a Model class?

the generated code should be public DbSet<Person> Persons { get; set; }

Can I make ZenSharp do that or do I really just need a live template?

@ulex
Copy link
Owner Author

ulex commented Jul 27, 2015

Can I make ZenSharp do that or do I really just need a live template?

Looks like you really need just a live template. Create live template public DBSet<$T$> $T$s {get; set; } and disable reformat option.

@ulex
Copy link
Owner Author

ulex commented Jul 27, 2015

It will be nice to have a editor for all rules and also if you can add alias to these rules

@adeel41 , For implement it really cool and useful feature I need to rewrite ZenSharp from scratch.
I'm using Nemerle PEG library for parse ZenSharp rules. It's really hard to do error recovery parsing with PEG parsers.

As workaround I can suggest syntax highlight rules for VIM -- https://github.com/ulex/ZenSharp/blob/126817389e719811869cbd4fd28eb1bd9d37f62c/ZenSharp.Core/ltg.vim

@ComanGames
Copy link

Hello i would like to create method what return the array for example int array.
And also i would like to add more then one parameter to that array
Can we made something like that:
pi[SomeName(s[Names,i[orderOfNames,t[ = public int[] SomeName(string[] Names, int[] orderOfNames, $type$ $name) {$END}

@ComanGames
Copy link

Окей я на первую проблему с мосивами ришения написал
image
primType ::= "int []"="i[" | "string []"="s[" | "double []"= "d[" |string=s | byte=by | bool=b | "System.DateTime"=dt | decimal=dc | double=d | int=i | uint=ui | "System.Guid"=g | "System.Uri"=u | "System.Xml.Linq.XElement"=x
А вот што касательно мульти параметров я хз

@ComanGames
Copy link

With those changes work like that
image

@ComanGames
Copy link

Okay great I done it.
image

@ComanGames
Copy link

image
image
Here how i done it. I still work on it.
But ZenSharp is great i fall in love with it

@ComanGames
Copy link

Now i want to made it work untill 5 variables and with ref out and params

@ComanGames
Copy link

Finally I done it support max 5 arguments modiffier of access and arrays
Uploading image.png…

@ComanGames
Copy link

image
Here how it look like

@ComanGames
Copy link

Here the source if someone is intresting
image

@ComanGames
Copy link

Super simple

@ComanGames
Copy link

Also i extend primitive types a little bit
image

@ulex
Copy link
Owner Author

ulex commented Nov 1, 2015

@GeorgeWolf, Thank you for your feedback!

Default templates allow you to enter array type by entering a symbol after type.
For example, to get

public int[] Test()
{
}

you should type pmiaTest. This is not showed in documentation — I will fix it soon.

Nice idea with [ for array of specific type. But ZenSharp have bugs with
ReSharper integration in this case. Highlighting goes crazy and auto inserted
pair of brakets ruins template completion. (this is clearly seen on your
screenshot)

Did you really find 5 parameters completion useful? From my point of view, much
more effecient way to construct method parameters is using R# quick fixed
Create parameter (from constructed method) and Add typed parameter (from
method usage).

ulex added a commit that referenced this issue Nov 1, 2015
@ComanGames
Copy link

Nice idea with [ for array of specific type. But ZenSharp have bugs with
ReSharper integration in this case. Highlighting goes crazy and auto inserted
pair of brakets ruins template completion. (this is clearly seen on your
screenshot)
-Yes but it sill working after i press tab it still making exactly what i want.
Did you really find 5 parameters completion useful? From my point of view, much
more effecient way to construct method parameters is using R# quick fixed
Create parameter (from constructed method) and Add typed parameter (from
method usage).

  • No it works very nice for me like usually i do method with one or two parameter what return array
  • Also how you see on my screenshot i add the method parameters modifier for me this one work super nice
    For me personally using of i[ is more natural way
    Here how it looks before i press tab
    image
    And after
    image
    Yes afto insted of pairs are working but after i press tab they are just gone

@ComanGames
Copy link

By the way i am really big fun of using IDE so i rewrite almost vsVim for my self. To make it perfect.
I would like to work on this project, the idea is super cool.
I train my self to get use to it. Next what i would like to add is put throw new NotImplementException();
After method is generated.

@ComanGames
Copy link

So for me it good like that
image
image

image

@olsh
Copy link

olsh commented Mar 16, 2016

Thanks for the great extension.
Is there any templates for async methods generation?

@ulex
Copy link
Owner Author

ulex commented Mar 21, 2016

@olsh sorry for long answer.

Currently, async templates not included in predefined templates.

But they are pretty easy to add.
For example, I can suggest use the following scheme:
pmTsName -> public async Task<string> Name() { }
pmTName -> public async Task Name{ }

this can be achieved by simple change in templates:

diff --git a/ZenSharp.Integration/Templates.ltg b/ZenSharp.Integration/Templates.ltg
index 7aef698..0eb368f 100644
--- a/ZenSharp.Integration/Templates.ltg
+++ b/ZenSharp.Integration/Templates.ltg
@@ -17,6 +16,7 @@ maybeType  ::= type | "void"
 type       ::= generic | primType ("?"="?")? ("[]"=a)? | suggType
 primType   ::= string=s | byte=by | bool=b | "System.DateTime"=dt | decimal=dc | double=d | int=i | uint=ui | "System.Guid"=g | "System.Uri"=u | "System.Xml.Linq.XElement"=x |
                object=o
+taskType   ::= "System.Threading.Tasks.Task"

 // Complex types:
 generic1 ::= (SCG "." ("IList"=l | "IEnumerable"="~")) "<" type ">"
@@ -40,7 +40,9 @@ methodAttributes ::=
     | "[NUnit.Framework.TearDownAttribute]"=td
     | "[NUnit.Framework.TestCaseAttribute]"=tc
     | "[NUnit.Framework.TestAttribute]"=t
-method ::= (methodAttributes)? access ("virtual "=vm | "abstract "=am | "static "=M | ""=m) (type | "void") space identifier methodArgs methodBody
+method_async ::= (methodAttributes)? access "async" space ("virtual "=vm | "abstract "=am | "static "=M | ""=m)   (taskType "<"=T type ">" | taskType ""=T) space identifier methodArgs methodBody
+method_generic ::= (methodAttributes)? access ("virtual "=vm | "abstract "=am | "static "=M | ""=m) (type | "void") space identifier methodArgs methodBody
+method ::= method_async | method_generic
 methodBody ::= " { " cursor " }"
 methodArgs ::=  "(" ((""="," | ""="(") arg)? ")"
 arg ::= primType " " identifier2

@ilivit
Copy link

ilivit commented Jun 7, 2016

I want to generate properties with PropertyChanged notifications. Here's the code transformation I want to achieve: ppsValue!+ converts to

    private string _value;
    public string Value
    {
        get { return _value; }
        set
        {
            if (value == _value) return;
            _value = value;
            OnPropertyChanged(nameof(Value));
        }
    }

Any way to do it with ZenSharp? I know it can be done with live templates or either with To Property With Change Notification conversion, but the way that ZenSharp proposes is more flexible IMO.

@ulex
Copy link
Owner Author

ulex commented Jun 8, 2016

@ilivit sorry, but currently it is not possible due bug in templates substitution (you need to substitute type twice in single template).
Will look at this soon, thanks.

@amadare42
Copy link

Hello. I really enjoy your extension. Is there some way to detect in-method or in-property scope?

@ulex
Copy link
Owner Author

ulex commented Aug 17, 2016

@amadare42 Unfortunately not.
But it is very nice and flexible idea how scope may be defined - by enclosing AST node type (or combination of it)

@garyng
Copy link

garyng commented Mar 27, 2017

Hi!
A suggestion here:
How about implementing delimiter/separators?
Like p\s\c\Testing will expand into public sealed class Testing{}
(because pscTesting will expand into public string cTesting;
image
)
I used \ as it is easier to type, any other delimiters can be used.

Any idea? 😄

Edit: I wrote a post about ZenSharp templates with more examples: https://garyng.github.io/gtil-gitbook/ReSharper/resharper-plugin-zensharp.html
😉

@ulex
Copy link
Owner Author

ulex commented Mar 27, 2017

@garyng this is just conflict of priorities. You can modify your ltg file this way to fix it:

scope "InCSharpClass" {
  start    ::= class |  method | property | field | const | other
  other ::=
	| ""=dbset "public DBSet<" identifier " > " identifier "s {get; set; }"
}

I would be nice to have some automatic verification tool to find such conflicts 😄

Edit: I wrote a post about ZenSharp templates with more example

thanks, I have added link to the README.md 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants