dotnet / dotnet/roslynator

Refactoring request: Use MathF where possible

Open
#1,365 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Analyzers Feature Request up-for-grabs
Dominant language
C#
Stars
3.5k
Forks
294
Avg merge
2h 30m
Merged PRs (30d)
4

Description

If you use any of the Math functions like Math.Min() or Math.Cos() or Math.Abs() etc, and you are using floats for all the parameters, then you should probably be using MathF for better performance.

Especially if you are casting to float immediately afterwards.

Note: This is only available if using .NET 6 or later

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by searching the C# source for Math calls whose parameters are floats, especially calls immediately cast to float. Check whether each location targets .NET 6 or later before considering MathF. Done means eligible calls use MathF without changing behavior, while cases requiring Math remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.