https://github.com/bdrupieski/swiftersharp
Make C# more like Swift
https://github.com/bdrupieski/swiftersharp
code-analysis csharp roslyn-analyzer swift
Last synced: 7 days ago
JSON representation
Make C# more like Swift
- Host: GitHub
- URL: https://github.com/bdrupieski/swiftersharp
- Owner: bdrupieski
- License: mit
- Created: 2018-06-30T21:49:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-04T12:58:52.000Z (over 7 years ago)
- Last Synced: 2025-10-06T07:38:17.900Z (11 days ago)
- Topics: code-analysis, csharp, roslyn-analyzer, swift
- Language: C#
- Size: 43.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SwifterSharp
Make C# more like Swift.
## Summary
This project is a collection of C# code analyzers that make C# act
more like Swift. Right now it's a collection of one.Pull requests are welcome.
## Why do this?
A coworker showed me in Swift you can _require_ named arguments
when calling a method. In C# these are optional except in a few
circumstances.This is a feature I wish C# had. There are some situations when I
wish I could require callers to explicitly name all arguments, like
to try to prevent transposed arguments or to make transposed
arguments easier to identify. This project is my attempt to add
this feature to C# and make it work more like Swift.Maybe I'll add more features if I'm further proselytized.
## Analyzers
### ForceNamedArguments
If you add the attribute `ForceNamedArguments` to a method, then
all callers will be forced to explicitly name all arguments when
calling that method. By default not naming all arguments will
result in a compiler error.For example:
```csharp
[ForceNamedArguments]
public static void Work(int x, int y, int z)
{
// some work
}
```Without all arguments named:

With all arguments named:

There's currently no code fix for this error in this package.
Additionally, this attribute currently only targets methods. It could
conceivably also target individual method parameters, selectively
requiring some but not all arguments to be named.## Configuring Analyzers
Analyzer rule severity can be changed by right-clicking the analyzer in
the solution explorer in Visual Studio. For example, to change the
ForceNamedArguments analyzer from its default, an error, to a warning:
If you're not using Visual Studio, since you don't need to in today's
cross-platform world, you can also add a ruleset to your project
or solution and add entries to change SwifterSharp rule severities:```xml
```