介绍
基于https://marketplace.visualstudio.com/items?itemName=bard83.csharpextension&ssr=false#overview
仅仅修改了命名空间的生成规则
修改了fromFilepath方法,命名空间从unity的Scripts之后的文件夹开始,
通过设置layer可以自定义拼接的层级,会加上Assets前的目录名称,也就是项目名称
可以设置jointName设置在末尾拼接的字符串,解决Entity目录下有Entity类的问题
C# Extensions
Welcome to C# Extensions. This VSCode extension provides extensions to the IDE that will hopefully speed up your development workflow.
It can currently be found at:
Features
Add C# Class
Add C# Enum
Add C# Interface
Add constructor from properties
Add body expression constructor from properties
This extension traverses up the folder tree to find the project.json or *.csproj and uses that as the parent folder to determine namespaces.
Custom Templates
Definition
The custom template must be defined in the vscode settings.json
file. Access to File->Preference->Settings, Explode the Extensions section and select C# Extension then click on edit in settings.json
.In the new section csharpextensions.templates
must define the list of items
which contain the custom templates. An item template is defined like below:
{
"name": "MyCustomTemplate",
"visibility": "public",
"construct": "class",
"description": "My awesome c# template",
"header": "using System;\nusing System.Runtime.Serialization;\nusing System.Text.Json;",
"attributes": [
"DbContext(typeof(AppDbContext))",
"Migration(\"${classname}\")"
],
"genericsDefinition": "I,J,K",
"declaration": "ISerializable, IEquatable",
"genericsWhereClauses": [
"where I : class",
"where J : struct",
"where K : IMyInterface",
],
"body": "public void MyFancyMethod(string variable)\n{\n System.Console.WriteLine(\"Hello World\");\n}"
}
visibility
C# component visibility (public, private and etc...);
construct
actually supported class
, interface
and struct
;
header
is used to group all the necessary usings module. Each using must be separated by a ;
. The keyword using
or the new line \n
can be omitted. "using System;\nusing System.Runtime.Serialization;\nusing System.Text.Json;" and "System;System.Runtime.Serialization;System.Text.Json" produce the same output. Implicit usings rules will be applied.
genericsDefinition
used to specify the generics for the construct automatically enclosed between <>
;
declaration
used to append all the necessary extended or implemented class or interface. The colon before the declaration will be automatically added. It could be used to add also generic clauses.
attributes
used to specify the attributes for the construct. The attributes must be specified in a list of string. Using the placeholder ${classname}
the construct name will be replaced instead.
genericsWhereClauses
used to define the generics where clauses inside the custom template.
body
body of template. It might be whatever C# code. The placeholder ${classname}
gets replaced with the file name if it's defined.
Please note that the code defined inside the custom template should be valid C# code. This extension does not perform any validation on it.
Add new custom template
Licence
MIT
See licence.txt
Legacy Repositories: