https://github.com/oleghcp/vssnippets
Snippets for Visual Studio
https://github.com/oleghcp/vssnippets
snippet visual-studio vs
Last synced: 3 months ago
JSON representation
Snippets for Visual Studio
- Host: GitHub
- URL: https://github.com/oleghcp/vssnippets
- Owner: oleghcp
- Created: 2024-03-27T16:55:41.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-08T15:29:16.000Z (about 2 years ago)
- Last Synced: 2025-04-07T20:43:48.169Z (about 1 year ago)
- Topics: snippet, visual-studio, vs
- Language: Vim Snippet
- Homepage:
- Size: 151 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Snippets for Visual Studio
Place snippet files to the snippet folder in addition to existing ones.
For example for vs 2022 it is:
`C:\Program Files\Microsoft Visual Studio\2022\Community\VC#\Snippets\1033\Visual C#\`
## Common C# Snippets
### Method

```csharp
void MyMethod()
{
throw new System.NotImplementedException();
}
```
### Deconstructor

```csharp
public void Deconstruct()
{
}
```
### Yield return

```csharp
yield return null;
```
### fixed

```csharp
fixed (void* ptr = value)
{
}
```
### StructLayout

```csharp
[StructLayout(LayoutKind.Sequential, Pack = 1)]
```
### MethodImpl

```csharp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
```
## For Unity
### Debug.Log();

```csharp
Debug.Log();
```
### SerializeField

```csharp
[SerializeField]
```
### SerializeReference

```csharp
[SerializeReference]
```
### UnityObject

```csharp
using UnityObject = UnityEngine.Object;
```
### #if UNITY_EDITOR

```csharp
#if UNITY_EDITOR
#endif
```
### #if UNITY_EDITOR || DEVELOPMENT_BUILD

```csharp
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#endif
```
### rectTransform property

```csharp
#pragma warning disable IDE1006
public RectTransform rectTransform => transform as RectTransform;
#pragma warning restore IDE1006
```
### OnValidate + Reset

```csharp
#if UNITY_EDITOR
private void OnValidate()
{
ValidateData();
}
private void Reset()
{
ValidateData();
}
private void ValidateData()
{
}
#endif
```
### CustomEditor

```csharp
[CustomEditor(typeof(ExampleClass))]
```
### CustomPropertyDrawer

```csharp
[CustomPropertyDrawer(typeof(CustomType))]
```