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

Implements support for Visual Studio Templates #9

Closed
wants to merge 6 commits into from

Conversation

sameera
Copy link
Contributor

@sameera sameera commented Nov 2, 2015

Matches user's input to a Visual Studio Template when available
and enables quick creation of C# classes and interfaces by using
c:class_name and i:interface_name syntax in the "Add New File"
dialog box.

sameera and others added 2 commits Nov 2, 2015
Matches user's input to a Visual Studio Template when available
and enables quick creation of C# classes and interfaces by using
c:<class_name> and i:<interface_name> syntax in the "Add New File"
dialog box.
@madskristensen
Copy link
Owner

@madskristensen madskristensen commented Nov 2, 2015

Awesome!!!

Should we make it so that the C#/VB interface templates are invoked simply by any file name starting with a capital i and the second character be any uppercase char? For instance:

IFoo.cs wil automatically invoke the C# interface template. Dummy regex: ^I[A-Z].+\.cs$

@sameera
Copy link
Contributor Author

@sameera sameera commented Nov 3, 2015

@madskristensen
+1. Makes sense. I personally don't use that convention (I've been working with Java folks for so long :) which is why I didn't add it.
I'll make the following changes:

  • Support I<interface_name>.cs, I<interface_name>.vb convention for adding interfaces
  • <name>.cs will default to C# classes (rather than empty code file), since this is the more common scenario
  • Assign e:<name>.cs syntax to creating an empty code file (with namespace declared)

I think, while I'm at it, I might as well move the patterns to an external file. Then even without a Options dialog page, anyone can add their own patterns. So, this pull will take some time.
May be you can merge this pull in the meantime, so that anyone else who wants the code now, can get it? :)

sameera added 3 commits Nov 7, 2015
Patterns are now loaded from Patterns.json file inside the
user's AppData folder when the plugin is first invoked.
I also had to refactor the code a bit to simplify how the
JSON file would be structured.
Some additional refactoring was done so that the pattern
matching happens only on the file name, rather than the full
relative path to the file.
…into easyTemplates

Merging the the Class1.cs delete from GitHub
Replaced JSON.NET with System.Runtime.Serialization.Json to
remove the external dependency.
@sameera
Copy link
Contributor Author

@sameera sameera commented Nov 7, 2015

So, now:

  • I<name>.cs or I<name>.vb will automatically generate Interfaces
  • <name>.cs will generate a C# class

Patterns can be managed by editing the %appdata%\VisualStudio.AddAnyFile\Patterns.json file.
I dropped JSON.net and stuck with System.Runtime.Serialization.Json which doesn't let me pretty print the JSON. So, if you want to edit this file, you can use a tool such as JSON Viewer plugin in Notepad++

@sameera sameera mentioned this pull request Nov 7, 2015
@sameera
Copy link
Contributor Author

@sameera sameera commented Nov 9, 2015

Did minor refactoring so that the user is not prompted for a file name if there's no project selection on the Solution Explorer.

@madskristensen
Copy link
Owner

@madskristensen madskristensen commented Jan 11, 2016

I can merge this as soon as the merge conflicts have been resolved. Then I'll also fix the issue with the references to VS2015-only assemblies.

@sameera
Copy link
Contributor Author

@sameera sameera commented Jan 12, 2016

I created PR #14 merging latest from this repo.

@sameera sameera closed this Jan 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants