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

Fix missing redundant event function quick fix #1864

Merged
merged 2 commits into from
Sep 28, 2020
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ Since 2018.1, the version numbers and release cycle match Rider's versions and r
* [Commits](https://github.com/JetBrains/resharper-unity/compare/net202...net203)
* [Milestone](https://github.com/JetBrains/resharper-unity/milestone/41?closed=1)

### Added

- Rider: Run Unity menu item handlers via gutter icon ([RIDER-35911](https://youtrack.jetbrains.com/issue/RIDER-35911), [#1857](https://github.com/JetBrains/resharper-unity/pull/1857))

### Changed

- Rider: Add define symbols based on pragmas in shader files, such as `multi_compile`, `shader_feature`, `target`, `geometry`, etc. ([RIDER-49527](https://youtrack.jetbrains.com/issue/RIDER-49527), [#1826](https://github.com/JetBrains/resharper-unity/pull/1826))
- Rider: Launch Unity if not already running when trying to run, debug or cover unit tests ([#1831](https://github.com/JetBrains/resharper-unity/pull/1831))
- Rider: Replace Clear on Play option in Unity log view with filters for last play mode and last AppDomain reload ([RIDER-49887](https://youtrack.jetbrains.com/issue/RIDER-49887), [RIDER-15476](https://youtrack.jetbrains.com/issue/RIDER-15476) [#1833](https://github.com/JetBrains/resharper-unity/pull/1831))
- Rider: Move Open Editor Log and Open Player Log actions to Unity log view main toolbar ([#1833](https://github.com/JetBrains/resharper-unity/pull/1831))

### Fixed

- Fix missing "remove redundant event function" quick fix ([#1860](https://github.com/JetBrains/resharper-unity/issues/1860), [#1864](https://github.com/JetBrains/resharper-unity/pull/1864))
- Rider: Fix ignoring `[Explicit]` attribute on unit tests ([#1731](https://github.com/JetBrains/resharper-unity/issues/1731), [RIDER-48686](https://youtrack.jetbrains.com/issue/RIDER-48686), [#1825](https://github.com/JetBrains/resharper-unity/pull/1825))
- Rider: Handle parameterized test fixtures with parameterized tests ([RIDER-46658](https://youtrack.jetbrains.com/issue/RIDER-46658), [#1825](https://github.com/JetBrains/resharper-unity/pull/1825))
- Rider: Fix infinite "refreshing solution" when no connection to Unity editor plugin ([#1601](https://github.com/JetBrains/resharper-unity/issues/1601), [RIDER-48690](https://youtrack.jetbrains.com/issue/RIDER-48690), [#1828](https://github.com/JetBrains/resharper-unity/pull/1828))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution

var session = manager.CreateHotspotSessionAtopExistingText(solution, invalidRange,
textControl, LiveTemplatesManager.EscapeAction.LeaveTextAndCaret, fieldInfos);
session.Execute();
session.ExecuteAndForget();
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using JetBrains.Application;
using JetBrains.Lifetimes;
using JetBrains.ReSharper.Feature.Services.QuickFixes;
using JetBrains.ReSharper.Intentions.QuickFixes.UsageChecking;
using JetBrains.ReSharper.Plugins.Unity.CSharp.Daemon.Errors;

namespace JetBrains.ReSharper.Plugins.Unity.CSharp.Feature.Services.QuickFixes
{
// Most QuickFixes are auto-registered, via [QuickFix] and ctor injection.
// Manual registration allows us to reuse an existing quick fix with a different highlighting.
[ShellComponent]
public class QuickFixRegistrar
{
public QuickFixRegistrar(Lifetime lifetime, IQuickFixes table)
{
table.RegisterQuickFix<RedundantEventFunctionWarning>(lifetime,
h => new RemoveUnusedElementFix(h.MethodDeclaration, "Remove redundant Unity event function"),
typeof(RemoveUnusedElementFix));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,5 @@ public override void Execute()
var attributeList = AttributeListNavigator.GetByAttribute(myAttribute);
attributeList?.RemoveAttribute(myAttribute);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using UnityEngine;

public class MyBehaviour : MonoBehaviour
{
public void U{caret}pdate()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using UnityEngine;

public class MyBehaviour : MonoBehaviour
{
|public void Update()
{
}|(0)
}

------------------------------------------------
0: Redundant Unity event function
QUICKFIXES:
Remove redundant Unity event function
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using UnityEngine;

public class MyBehaviour : MonoBehaviour
{
public void DoSomething()
{
Update();
}

public void U{caret}pdate()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using UnityEngine;

public class MyBehaviour : MonoBehaviour
{
public void DoSomething()
{
Update();
}

|public void Update()
{
}|(0)
}

------------------------------------------------
0: Redundant Unity event function
QUICKFIXES:
Remove redundant Unity event function
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using UnityEngine;

public class MyBehaviour : MonoBehaviour
{
public void D{caret}oSomething()
{
}

public void Update()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using UnityEngine;

public class MyBehaviour : MonoBehaviour
{
public void DoSomething()
{
}

|public void Update()
{
}|(0)
}

------------------------------------------------
0: Redundant Unity event function
QUICKFIXES:
Remove redundant Unity event function
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using UnityEngine;

public class MyBehaviour : MonoBehaviour
{
public void U{caret}pdate()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using UnityEngine;

public class MyBehaviour : MonoBehaviour
{{caret}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using UnityEngine;

public class MyBehaviour : MonoBehaviour
{
public void DoSomething()
{
Update();
}

public void U{caret}pdate()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using UnityEngine;

public class MyBehaviour : MonoBehaviour
{
public void DoSomething()
{
}
{caret}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using JetBrains.ReSharper.FeaturesTestFramework.Intentions;
using JetBrains.ReSharper.Intentions.QuickFixes.UsageChecking;
using NUnit.Framework;

namespace JetBrains.ReSharper.Plugins.Unity.Tests.CSharp.Intentions.QuickFixes
{
[TestUnity]
public class RedundantEventFunctionQuickFixAvailabilityTests : QuickFixAvailabilityTestBase
{
protected override string RelativeTestDataPath => @"CSharp\Intentions\QuickFixes\RedundantEventFunction\Availability";

[Test] public void Test01() { DoNamedTest(); }
[Test] public void Test02() { DoNamedTest(); }
[Test] public void Test03() { DoNamedTest(); }
}

[TestUnity]
public class RedundantEventFunctionQuickFixTests : CSharpQuickFixTestBase<RemoveUnusedElementFix>
{
protected override string RelativeTestDataPath => @"CSharp\Intentions\QuickFixes\RedundantEventFunction";

[Test] public void Test01() { DoNamedTest(); }
[Test] public void Test02() { DoNamedTest(); }
}
}