Skip to content

Quick fix for NonAlloc API #784

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 12 commits into from
Sep 21, 2018
Merged

Quick fix for NonAlloc API #784

merged 12 commits into from
Sep 21, 2018

Conversation

krasnotsvetov
Copy link
Collaborator

Functions like SphereCast, RaycastAll, CapsuleCast e.t.c has NonAlloc version, analyzer generates warnings when user uses this functions. In some cases, where we can improve user code without unexpected affect quickfix is provided.

else
{
newName = originName + "NonAlloc";
}
Copy link
Member

Choose a reason for hiding this comment

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

Move this section below the check for type, or we'll be doing this for every method invocation in the project.

var table = type.GetSymbolTable(expression.PsiModule).Filter(
new AccessRightsFilter(new DefaultAccessContext(expression)),
new ExactNameFilter(newName),
new PredicateFilter(t => MatchSignatureAllocToNonAlloc(method, t.GetDeclaredElement() as IMethod)));
Copy link
Member

Choose a reason for hiding this comment

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

Is this heuristic good enough to capture all of the methods we need? Can we rely on naming and parameter size +1? Would it be easier to just have a map of allocating to non-allocating methods?

@citizenmatt citizenmatt added this to the Rider 2018.3 milestone Sep 17, 2018
Copy link
Member

@citizenmatt citizenmatt left a comment

Choose a reason for hiding this comment

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

How about instead of a dictionary for two known types, you have two dictionaries, one for Physics and the other for Physics2D? Each dictionary is a map of original name to new name, so we don't have to rely on ending with NonAlloc

@krasnotsvetov krasnotsvetov merged commit 4df2434 into 183 Sep 21, 2018
@krasnotsvetov krasnotsvetov deleted the 183-vk-qf-nonallocapi branch September 21, 2018 15:03
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.

2 participants