Closed viceroypenguin closed 5 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
a0f72ab
) 92.50% compared to head (4248492
) 92.50%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
NB: All of the CodeFactor issues are pre-existing and should be addressed separately.
This is a pre-requisite for #947
Are you sure? How? I don't think implicit usings are a great idea, especially because they make it difficult to understand the code base and exclude embedding scenarios. They may have their place in some projects, but don't think this is one of those.
Noted in this comment.
I have a few more minutes to respond, so here goes:
ImplicitUsings
exclude embedding scenarios.
I'll disagree with this for two reasons:
ImplicitUsings
enabled; this is because all of the default templates since net6+ have it enabled in the .csproj, for the convenience of top-level programs. As such, if anyone were to copy files from MoreLinq into their projects, they are more likely to be working with the default ImplicitUsings
.it difficult to understand the code base
What does removing using System;
make harder to understand? I think most developers can agree that IDisposable
and ArgumentNullException
come from the System
namespace, and IList<>
comes from the System.Collection.Generic
namespace. And if they don't know that, then a) are they working with the MoreLinq codebase in the first place, and b) do they care? The default implicit usings contain the following namespaces:
System
System.Collections.Generic
System.Linq
System.Text
System.Threading.Tasks
Which classes from these namespaces are difficult to understand where they come from or how they are used? And which of these classes are likely to overlap with any code written by us or other developers?
System.Collections.Generic.IEnumerable<>
on every return type for clarity. using
or not - and if you use the class, VS automatically includes a using
statement for that namespace in the file. ImplicitUsings
is necessaryThat all said, the problem with not using ImplicitUsings
or global using System;
is that we cannot use a global using
for ArgumentNullException
if using System;
is present at the top of the file. The file and/or namespace using
s have higher priority than the global using
s. As such, if each file has using System;
, then each file must separately have the following code at the top fo the file:
namespace MoreLinq
{
using System;
#if !NET6_0_OR_GREATER
using ArgumentNullException = MoreLinq.Exceptions.ArgumentNullException;
#endif
#if !NET8_0_OR_GREATER
using ArgumentOutOfRangeException = MoreLinq.Exceptions.ArgumentOutOfRangeException;
#endif
// code
}
I think that this is untenable to have across the project.
GlobalUsings.cs
file with the necessary global using
s, for System
and for the aliases.#ifdef
s in a majority of files.
This PR enables
ImplicitUsings
on the MoreLinq project and removes (now-)unnecessaryusing
s on relevant files. This is a pre-requisite for #947Open questions:
ImplicitUsings
on the other projects as well?using
s we should add to/remove from the implicit set? I could make the argument to removeSystem.Linq
from the set, or to addSystem.Collections
to the set of implicit usings, for example.GlobalUsings.cs
file instead of enablingImplicitUsings
? I preferImplicitUsings
, because I don't like random files with no code, butGlobalUsings.cs
would be more explicit.