JetBrains / resharper-unity

Unity support for both ReSharper and Rider
Apache License 2.0
1.21k stars 131 forks source link

The pattern where the File Layout settings for Unity only work in Rider and not in ReSharper. #2439

Closed sr4dev closed 2 months ago

sr4dev commented 2 months ago

When I use Windows, I use Visual Studio + ReSharper, and when I'm on a Mac, I develop using Rider. Recently, I updated to ReSharper 2024.1.1 and Rider 2024.1.1.

After the update, the File Layout for Unity that used to work well is no longer working in ReSharper, but it still works in Rider.

Below is the Unity File Layout that I am using.

XML <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns" xmlns:unity="urn:schemas-jetbrains-com:member-reordering-patterns-unity"> <TypePattern DisplayName="Serializable Type" RemoveRegions="All" Priority="100"> <TypePattern.Match> <unity:SerializableClass /> </TypePattern.Match> <Entry DisplayName="Static Fields and Constants"> <Entry.Match> <Or> <Kind Is="Constant" /> <And> <Kind Is="Field" /> <Static /> </And> </Or> </Entry.Match> <Entry.SortBy> <Kind Order="Constant Field" /> </Entry.SortBy> </Entry> <Entry DisplayName="Nested Types"> <Entry.Match> <Kind Is="Enum" /> </Entry.Match> </Entry> <Entry DisplayName="Public Enums" Priority="100"> <Entry.Match> <And> <Access Is="Public" /> <Kind Is="Enum" /> </And> </Entry.Match> <Entry.SortBy> <Name /> </Entry.SortBy> </Entry> <Region Name="Inspector"> <Entry DisplayName="Serialized Fields"> <Entry.Match> <!-- Keep serialised fields and auto-properties with serialised backing fields together, unsorted, to maintain order in the Inspector window --> <Or> <unity:SerializedField /> <unity:AutoPropertyWithSerializedBackingField /> </Or> </Entry.Match> <!-- No sorting --> </Entry> </Region> <Entry DisplayName="Non-serialised Fields"> <Entry.Match> <And> <Kind Is="Field" /> <Not> <unity:SerializedField /> </Not> </And> </Entry.Match> <Entry.SortBy> <Readonly /> </Entry.SortBy> </Entry> <Entry DisplayName="Public Delegates" Priority="100"> <Entry.Match> <And> <Access Is="Public" /> <Kind Is="Delegate" /> </And> </Entry.Match> <Entry.SortBy> <Name /> </Entry.SortBy> </Entry> <Entry DisplayName="Auto Properties"> <Entry.Match> <Kind Is="Autoproperty" /> </Entry.Match> </Entry> <Entry DisplayName="Properties, Indexers"> <Entry.Match> <Or> <Kind Is="Property" /> <Kind Is="Indexer" /> </Or> </Entry.Match> </Entry> <Entry DisplayName="Interface Implementations" Priority="100"> <Entry.Match> <And> <Or> <Kind Is="Property" /> <Kind Is="Indexer" /> </Or> <ImplementsInterface /> </And> </Entry.Match> <Entry.SortBy> <ImplementsInterface Immediate="True" /> </Entry.SortBy> </Entry> <Entry DisplayName="RuntimeInitializeOnLoadMethod"> <Entry.Match> <HasAttribute Name="UnityEngine.RuntimeInitializeOnLoadMethod" /> </Entry.Match> </Entry> <Entry DisplayName="Constructors"> <Entry.Match> <Kind Is="Constructor" /> </Entry.Match> <Entry.SortBy> <Static /> </Entry.SortBy> </Entry> <Region Name="Unity Event"> <Entry DisplayName="Event Functions"> <Entry.Match> <unity:EventFunction /> </Entry.Match> </Entry> </Region> <Entry DisplayName="Interface Implementations" Priority="100"> <Entry.Match> <And> <Kind Is="Member" /> <ImplementsInterface /> </And> </Entry.Match> <Entry.SortBy> <ImplementsInterface Immediate="True" /> </Entry.SortBy> </Entry> <Entry DisplayName="Nested Types"> <Entry.Match> <Kind Is="Type" /> </Entry.Match> </Entry> <Entry DisplayName="All other members"> <Entry.SortBy> <Access /> <Static /> </Entry.SortBy> </Entry> </TypePattern> <TypePattern DisplayName="Default Pattern" RemoveRegions="All"> <TypePattern.Match> <Not> <Or> <HasAttribute Name="System.Serializable" Target="Type" /> <InheritsFromType Name="UnityEngine.Object" /> </Or> </Not> </TypePattern.Match> <Entry DisplayName="Static Fields and Constants"> <Entry.Match> <Or> <Kind Is="Constant" /> <And> <Kind Is="Field" /> <Static /> </And> </Or> </Entry.Match> <Entry.SortBy> <Kind Order="Constant Field" /> </Entry.SortBy> </Entry> <Entry DisplayName="Nested Types"> <Entry.Match> <Kind Is="Enum" /> </Entry.Match> </Entry> <Entry DisplayName="Public Enums" Priority="100"> <Entry.Match> <And> <Access Is="Public" /> <Kind Is="Enum" /> </And> </Entry.Match> <Entry.SortBy> <Name /> </Entry.SortBy> </Entry> <Entry DisplayName="Fields"> <Entry.Match> <And> <Kind Is="Field" /> <Not> <Static /> </Not> </And> </Entry.Match> <Entry.SortBy> <Readonly /> <Static /> <Virtual /> </Entry.SortBy> </Entry> <Entry DisplayName="Public Delegates" Priority="100"> <Entry.Match> <And> <Access Is="Public" /> <Kind Is="Delegate" /> </And> </Entry.Match> <Entry.SortBy> <Name /> </Entry.SortBy> </Entry> <Entry DisplayName="Properties, Indexers"> <Entry.Match> <Or> <Kind Is="Property" /> <Kind Is="Indexer" /> </Or> </Entry.Match> </Entry> <Entry DisplayName="Constructors"> <Entry.Match> <Kind Is="Constructor" /> </Entry.Match> <Entry.SortBy> <Static /> </Entry.SortBy> </Entry> <Entry DisplayName="Interface Implementations" Priority="100"> <Entry.Match> <And> <Kind Is="Member" /> <ImplementsInterface /> </And> </Entry.Match> <Entry.SortBy> <ImplementsInterface Immediate="True" /> </Entry.SortBy> </Entry> <Entry DisplayName="All other members"> <Entry.SortBy> <Access /> <Static /> </Entry.SortBy> </Entry> <Entry DisplayName="Nested Types"> <Entry.Match> <Kind Is="Type" /> </Entry.Match> </Entry> </TypePattern> </Patterns>

Below is the .DotSettings file that I am using. dotsettings.zip

By the way, is there any plan to add a Unity-specific File Layout tab to ReSharper? When I need to edit the File Layout for Unity, I follow the method described at https://github.com/JetBrains/resharper-unity/issues/1771, but this method is quite painful.

sr4dev commented 2 months ago

I have identified the pattern.

The Unity scripts like MonoBehaviour and ScriptableObject are not using the Unity File Layout; instead, they're using a standard File Layout.

Update: It seems that the Unity Support Extension is not being recognized in ReSharper 2024.1.1.

ReSharper 2023.3.4 + Unity Support 2023.3.2.100 image

ReSharper 2024.1.1 + Unity Support 2024.1.0.307 image

citizenmatt commented 2 months ago

That's very unexpected. I have ReSharper 2024.1.1 and Unity Support 2024.1.0.307 installed just fine. I'm not seeing it marked as "incompatible", and don't understand how we could have different results there. Have you restarted VS since installing the Unity Support plugin? It might be worth uninstalling, restarting VS and reinstalling.

sr4dev commented 2 months ago

Yes, whenever I upgraded ReSharper or downgraded it, I always restarted VS. I also restarted VS every time I installed Unity Support or deleted the existing version.

However, I haven't rebooted my PC yet. I'll try that later. I'll also try reinstalling VS.

citizenmatt commented 2 months ago

Shouldn't need to restart your PC or reinstall VS. It might be that you need to install ReSharper C++. The shader support in the Unity plugin uses the C++ engine to parse the code, but previous versions have been ok to run without it installed. Something might have changed.

sr4dev commented 2 months ago

Thank you for the feedback! Installing ReSharper++ solved all the issues!