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

Introduce "Unity Class" and "Unity Shader" grouped file templates #1983

Merged
merged 3 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ Since 2018.1, the version numbers and release cycle match Rider's versions and r
* [Commits](https://github.com/JetBrains/resharper-unity/compare/net203...net211)
* [Milestone](https://github.com/JetBrains/resharper-unity/milestone/42?closed=1)

### Changed

- Rider: Unity file templates are grouped into "Unity Class" and "Unity Shader" ([#1983](https://github.com/JetBrains/resharper-unity/pull/1983))

### Fixed

- Rider: Fix issue launching Unity when debugging and editor isn't running ([RIDER-52498](https://youtrack.jetbrains.com/issue/RIDER-52498), [#1920](https://github.com/JetBrains/resharper-unity/pull/1920))
- Rider: Fix exception with multiple assemblies with the same name ([RIDER-54876](https://youtrack.jetbrains.com/issue/RIDER-54876), [#1953](https://github.com/JetBrains/resharper-unity/pull/1953))
- Rider: Fix exception in protocol file watcher ([DEXP-559833](https://youtrack.jetbrains.com/issue/DEXP-559833), [#1942](https://github.com/JetBrains/resharper-unity/pull/1942))
- Rider: Fix files in `Packages` folder showing the non-project dialog when being modified ([#1997](https://github.com/JetBrains/resharper-unity/pull/1997))


Expand All @@ -26,11 +33,11 @@ Since 2018.1, the version numbers and release cycle match Rider's versions and r
* [GitHub release](https://github.com/JetBrains/resharper-unity/releases/tag/net203-rtm-2020.3.1)
* [ReSharper release](https://resharper-plugins.jetbrains.com/packages/JetBrains.Unity/2020.3.1.132)

# Changed
### Changed

- Disable performance and Burst context with comment ([#1948](https://github.com/JetBrains/resharper-unity/pull/1948))

# Fixed
### Fixed

- Fix performance context and Burst actions not showing if caret was on first character of method declaration ([#1948](https://github.com/JetBrains/resharper-unity/pull/1948))
- Rider: Fix showing incorrect Code Vision link for expensive code ([#1948](https://github.com/JetBrains/resharper-unity/pull/1948))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using JetBrains.ReSharper.Feature.Services.LiveTemplates.Scope;

namespace JetBrains.ReSharper.Plugins.Unity.CSharp.Feature.Services.LiveTemplates.Scope
{
// A dummy scope point that all Unity templates declare so that they are sorted and grouped together in Rider.
// Rider uses the first scope point to group templates into sections (see RIDER-10132). If templates are available
// due to different scope points (e.g. InUnityCSharpProject vs InUnityCSharpEditorFolder), then the templates are
// shown in separate sections, even if they are both conceptually "Unity" file templates. This also messes up UITag
// grouping, as each section will have it's own UITag instance, and we get multiple "Unity Class" entries.
// Introducing a dummy scope point as the first scope point for all Unity file templates means Rider will group all
// Unity file templates into a single section, and everything works as expected. This scope point is never published
// by a provider, so it doesn't matter if all templates declare it. It is visible in the UI for the templates, but
// appears as "Unity file template", so is not a major issue.
// Sort order of section groups is undefined (or at least implicit based on settings storage). The front end will
// boost templates in the C#/F#/VB project groups, and also Razor/Blazor templates.
// Bizarrely, presentable name does seem to matter, though. "Unity file template" sorts above resources and
// config files, while "Unity file template group" sorts below. I see no reason for this, so I guess it's just a
// side effect of how things are stored/read from settings storage.
public class UnityFileTemplateSectionMarker : TemplateScopePoint
{
private static readonly Guid ourDefaultUID = new Guid("C57D3F9D-BF90-42FB-BA95-2AEFA86AA872");

public override Guid GetDefaultUID() => ourDefaultUID;
public override string PresentableShortName => "Unity file template";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ public class UnityProjectScopeCategoryUIProvider : ScopeCategoryUIProvider
{
static UnityProjectScopeCategoryUIProvider()
{
// These get added to a static dictionary, so they can be referenced by name from templates
// We're using Unity_CSharp instead of just CSharp, because that's set up to use the C#
// template scope icon instead of the C# file icon - see RIDER-9903
TemplateImage.Register("UnityCSharp", PsiCSharpThemedIcons.Csharp.Id);
// UnityCSharp requires its own icon rather than the generic C# icon because it's used as the group icon
// for the UITag "Unity Class" menu item
TemplateImage.Register("UnityCSharp", UnityFileTypeThemedIcons.FileUnity.Id);
TemplateImage.Register("UnityShaderLab", ShaderFileTypeThemedIcons.FileShader.Id);
TemplateImage.Register("UnityAsmDef", PsiJavaScriptThemedIcons.Json.Id);
}
Expand All @@ -35,6 +34,11 @@ public UnityProjectScopeCategoryUIProvider()

public override IEnumerable<ITemplateScopePoint> BuildAllPoints()
{
// TODO: Remove this once RIDER-10132 is fixed
// Exposing this simply allows custom templates to be included in the same group (and "Unity Class" UITag)
// as the default templates.
yield return new UnityFileTemplateSectionMarker();

yield return new InUnityCSharpProject();
yield return new InUnityCSharpAssetsFolder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public class UnityProjectScopeProvider : ScopeProvider
{
public UnityProjectScopeProvider()
{
// Used when creating scope point from settings
// These factory methods are used to create scope points when reading templates from settings
Creators.Add(TryToCreate<UnityFileTemplateSectionMarker>);
Creators.Add(TryToCreate<InUnityCSharpProject>);
Creators.Add(TryToCreate<InUnityCSharpAssetsFolder>);
Creators.Add(TryToCreate<InUnityCSharpEditorFolder>);
Expand Down
2 changes: 1 addition & 1 deletion resharper/resharper-unity/src/Templates/File/AsmDef.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type: File
reformat: True
categories: unity
customProperties: Extension=asmdef, FileName=Assembly, ValidateFileName=True
scopes: InUnityCSharpProject;MustBeInProjectWithUnityVersion(version=2017.3)
scopes: UnityFileTemplateSectionMarker;InUnityCSharpProject;MustBeInProjectWithUnityVersion(version=2017.3)
parameterOrder: (NAME)
NAME-expression: getAlphaNumericFileNameWithoutExtension()
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=cs, FileName=AssetPostprocessor, ValidateFileName=True
scopes: InUnityCSharpEditorFolder
scopes: UnityFileTemplateSectionMarker;InUnityCSharpEditorFolder
uitag: Unity Class
parameterOrder: HEADER, (CLASS), (NAMESPACE)
HEADER-expression: fileheader()
CLASS-expression: getAlphaNumericFileNameWithoutExtension
Expand Down
3 changes: 2 additions & 1 deletion resharper/resharper-unity/src/Templates/File/CustomEditor.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=cs, FileName=CustomEditor, ValidateFileName=True
scopes: InUnityCSharpEditorFolder
scopes: UnityFileTemplateSectionMarker;InUnityCSharpEditorFolder
uitag: Unity Class
parameterOrder: HEADER, (CLASS), (NAMESPACE), TYPE
HEADER-expression: fileheader()
CLASS-expression: getAlphaNumericFileNameWithoutExtension
Expand Down
3 changes: 2 additions & 1 deletion resharper/resharper-unity/src/Templates/File/EditModeTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=cs, FileName=EditModeTest, ValidateFileName=True
scopes: InUnityCSharpEditorFolder;InUnityCSharpFirstpassEditorFolder
scopes: UnityFileTemplateSectionMarker;InUnityCSharpEditorFolder;InUnityCSharpFirstpassEditorFolder
uitag: Unity Class
parameterOrder: HEADER, (CLASS), (NAMESPACE)
HEADER-expression: fileheader()
CLASS-expression: getAlphaNumericFileNameWithoutExtension()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=cs, FileName=EditorEntryPoint, ValidateFileName=True
scopes: InUnityCSharpEditorFolder
scopes: UnityFileTemplateSectionMarker;InUnityCSharpEditorFolder
uitag: Unity Class
parameterOrder: HEADER, (CLASS), (NAMESPACE)
HEADER-expression: fileheader()
CLASS-expression: getAlphaNumericFileNameWithoutExtension()
Expand Down
3 changes: 2 additions & 1 deletion resharper/resharper-unity/src/Templates/File/EditorWindow.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=cs, FileName=EditorWindow, ValidateFileName=True
scopes: InUnityCSharpEditorFolder
scopes: UnityFileTemplateSectionMarker;InUnityCSharpEditorFolder
uitag: Unity Class
parameterOrder: HEADER, (CLASS), (NAMESPACE), MENUITEM, MENUITEMCOMMAND, TITLE
HEADER-expression: fileheader()
CLASS-expression: getAlphaNumericFileNameWithoutExtension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=shader, FileName=NewImageEffectShader, ValidateFileName=True
scopes: InUnityCSharpProject
scopes: UnityFileTemplateSectionMarker;InUnityCSharpProject
uitag: Unity Shader
parameterOrder: (NAME)
NAME-expression: getAlphaNumericFileNameWithoutExtension()
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=cs, FileName=MonoBehaviour, ValidateFileName=True
scopes: InUnityCSharpProject
scopes: UnityFileTemplateSectionMarker;InUnityCSharpProject
uitag: Unity Class
parameterOrder: HEADER, (CLASS), (NAMESPACE)
HEADER-expression: fileheader()
CLASS-expression: getAlphaNumericFileNameWithoutExtension()
Expand Down
3 changes: 2 additions & 1 deletion resharper/resharper-unity/src/Templates/File/PlayModeTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=cs, FileName=PlayModeTest, ValidateFileName=True
scopes: InUnityCSharpProject
scopes: UnityFileTemplateSectionMarker;InUnityCSharpProject
uitag: Unity Class
parameterOrder: HEADER, (CLASS), (NAMESPACE)
HEADER-expression: fileheader()
CLASS-expression: getAlphaNumericFileNameWithoutExtension()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=cs, FileName=PropertyDrawer, ValidateFileName=True
scopes: InUnityCSharpEditorFolder
scopes: UnityFileTemplateSectionMarker;InUnityCSharpEditorFolder
uitag: Unity Class
parameterOrder: HEADER, (CLASS), (NAMESPACE), TYPE
HEADER-expression: fileheader()
CLASS-expression: getAlphaNumericFileNameWithoutExtension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=cs, FileName=ScriptableObject, ValidateFileName=True
scopes: InUnityCSharpProject
scopes: UnityFileTemplateSectionMarker;InUnityCSharpProject
uitag: Unity Class
parameterOrder: HEADER, (CLASS), (NAMESPACE), FILENAME, MENUNAME
HEADER-expression: fileheader()
CLASS-expression: getAlphaNumericFileNameWithoutExtension()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=cs, FileName=ScriptableWizard, ValidateFileName=True
scopes: InUnityCSharpEditorFolder
scopes: UnityFileTemplateSectionMarker;InUnityCSharpEditorFolder
uitag: Unity Class
parameterOrder: HEADER, (CLASS), (NAMESPACE), MENUITEM, MENUITEMCOMMAND, TITLE, CREATE, OTHER
HEADER-expression: fileheader()
CLASS-expression: getAlphaNumericFileNameWithoutExtension()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=shader, FileName=NewSurfaceShader, ValidateFileName=True
scopes: InUnityCSharpProject
scopes: UnityFileTemplateSectionMarker;InUnityCSharpProject
uitag: Unity Shader
parameterOrder: (NAME)
NAME-expression: getAlphaNumericFileNameWithoutExtension()
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=cs, FileName=StateMachineBehaviour, ValidateFileName=True
scopes: InUnityCSharpProject
scopes: UnityFileTemplateSectionMarker;InUnityCSharpProject
uitag: Unity Class
parameterOrder: HEADER, (CLASS), (NAMESPACE)
HEADER-expression: fileheader()
CLASS-expression: getAlphaNumericFileNameWithoutExtension()
Expand Down
3 changes: 2 additions & 1 deletion resharper/resharper-unity/src/Templates/File/UnlitShader.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ reformat: True
shortenReferences: True
categories: unity
customProperties: Extension=shader, FileName=NewUnlitShader, ValidateFileName=True
scopes: InUnityCSharpProject
scopes: UnityFileTemplateSectionMarker;InUnityCSharpProject
uitag: Unity Shader
parameterOrder: (NAME)
NAME-expression: getAlphaNumericFileNameWithoutExtension()
---
Expand Down
2 changes: 1 addition & 1 deletion resharper/resharper-unity/src/resharper-unity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
</ItemGroup>
<!-- ********** -->
<ItemGroup Label="References">
<PackageReference Include="CitizenMatt.ReSharper.LiveTemplateCompiler" Version="2.6.0" />
<PackageReference Include="CitizenMatt.ReSharper.LiveTemplateCompiler" Version="2.8.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
6 changes: 3 additions & 3 deletions resharper/resharper-unity/src/rider-unity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
</ItemGroup>
<!-- ********** -->
<ItemGroup Label="References">
<PackageReference Include="CitizenMatt.ReSharper.LiveTemplateCompiler" Version="2.6.0" />
<PackageReference Include="CitizenMatt.ReSharper.LiveTemplateCompiler" Version="2.8.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net461" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -172,8 +172,8 @@
<EmbeddedResource Remove="**\ReSharper\**" />
<None Remove="**\ReSharper\**" />
</ItemGroup>
<Import Project="$(DotNetSdkPath)\Build\SubplatformReference.ReSharperAutomationTools_src_ReSharperHost.Props"/>
<Import Project="$(DotNetSdkPath)\Build\SubplatformReference.Psi.Features_Cpp_Src_Core.Props"/>
<Import Project="$(DotNetSdkPath)\Build\SubplatformReference.ReSharperAutomationTools_src_ReSharperHost.Props" />
<Import Project="$(DotNetSdkPath)\Build\SubplatformReference.Psi.Features_Cpp_Src_Core.Props" />
<Target Name="CppHack" AfterTargets="PrepareForRun">
<Move SourceFiles="$(OutDir)JetBrains.ReSharper.Psi.Cpp.dll" DestinationFiles="$(OutDir)x86\JetBrains.ReSharper.Psi.Cpp.dll" />
</Target>
Expand Down