Skip to content

Added UsageInspectionSuppresions for UnityEditor.Build.* #1167

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

Merged
merged 9 commits into from
Jun 5, 2019

Conversation

JurjenBiewenga
Copy link
Contributor

Fixes #686

All the interfaces in UnityEditor.Build implement the IOrderedCallback interface however I could not figure out how to make the callbackOrder property implicitly used.

@citizenmatt
Copy link
Member

Thanks for the contribution, unfortunately, this is not the correct approach. The api.xml file is intended to hold event functions, parsed from the "Messages" section of the Unity documentation. The methods listed in the file are marked as implicitly used by the UsageInspectionsSuppressor, but that is because they are event functions, not because this is how to mark them as in use. It also doesn't work with properties, only methods.

A more appropriate approach would be to add this directly to UsageInspectionsSuppressor, by adding explicit checks for methods and properties, by looking at the short name and verifying that they implement the appropriate interface. E.g.

case IProperty when IsOrderedCallbackMember():
  flags = ImplicitUseKindFlags.Access;
  return true;

and something similar for methods.

The implementation check would probably need to check the method or property's ShortName to see if it's an interesting member, and then call member.GetRootSuperMembers(false) and for each returned member, call rootMember.GetContainingType() and check to see if that type is UnityEditor.Build.IOrderedCallback.

@JurjenBiewenga
Copy link
Contributor Author

This solution might not work with different Unity versions in this form. I'm not sure how to test that however, any suggestions?

@citizenmatt citizenmatt added this to the Rider 2019.2 milestone Jun 3, 2019
@citizenmatt
Copy link
Member

Why do you think it might not work with other Unity versions?

{
throw new System.NotImplementedException();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add another case where the interface is being implicitly implemented via a base class, e.g.

public abstract class Base : IPostprocessBuild
{
  // …
  public abstract void OnPostProcessBuild();
}

and

public class Derived : Base
{
  public override void OnPostProcessBuild(…) { }
}

This should also help check if we can short circuit the type check.

@citizenmatt
Copy link
Member

Oh yeah, and can you add an "added" line in the CHANGELOG.md, plugin.xml and resharper-unity.nuspec, too, please?

@JurjenBiewenga
Copy link
Contributor Author

Where are the plugin.xml and the resharper-unity.nuspec located?

@citizenmatt
Copy link
Member

Simplified inheritance check of implicitly used interfaces
Merged switch cases
@citizenmatt
Copy link
Member

LGTM

@citizenmatt citizenmatt merged commit da1ebbf into JetBrains:192 Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Classes deriving from IPreprocessBuild and IPostprocessBuild should be marked implicitly used
2 participants