JetBrains / JetBrains/resharper-unity
Type Argument Specification Is Redundant
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 142
- PR merge metrics
- No merged PRs in 30d
Description
It seems whatever compiler Unity uses is not capable of inferring types in generics when passing in method groups.
For example:
```
public class Foo
{
private Dictionary> funcs = new Dictionary>();
public void AddFunc(Func func)
{
funcs.Add(typeof(T), (name) => func(name));
}
public Foo()
{
AddFunc(PlayerPrefs.GetString);
}
}
```
This is valid code, but does not compile in Unity because it seems incapable of deciding between the overloads of `PlayerPrefs.GetString(string key)` and `PlayerPrefs.GetString(string key, string defaultValue)`... probably a low priority bug in their mono compiler that's never been addressed.
Specifying the `` directly gets it to compile eg: `AddFunc(PlayerPrefs.GetString)`, but then R# flags this argument specification as redundant.
Contributor guide
Assessment
This issue has not been assessed yet.