Comments (3)
I'm a little hesitant to add this because it feels a bit outside the scope of CSharpier. The only two exceptions to the "only change whitespace" guideline were a pain to deal with due to figuring out how to get the syntax tree validation to not flag them as problems with code being lost.
Other modifiers are also unnecessary but it is pretty standard to always include them. Should CSharpier then enforce adding the following modifiers -
If no modifier is on an interface should CSharpier change it to public interface
?
Should classes without modifiers be changed to internal class
?
Should members of classes without modifiers have private
added?
from csharpier.
If the idea is to not change behavior, then your first example should probably be changed instead to internal interface
.
But, on further thought, I'm removing my vote. IMO the behavior would be less than obvious. For example, it would not make sense to change this
internal sealed class MaybeThisShouldBePublic
{
internal string MyInternalOnlyProperty { get; set; }
}
to this
internal sealed class MaybeThisShouldBePublic
{
public string MyInternalOnlyProperty { get; set; }
}
because even though the internal
modifier on the property is currently useless, if CSharpier were to change the property accessor to public
and then the user later changed the class to public
, CSharpier may have just exposed a property that shouldn't have been exposed. Even worse if they accidentally change a public
class to internal
, and CSharpier instantly changes all their properties to public
. So a case like that would need to be left alone. But to me as a user it wouldn't be obvious why CSharpier sometimes removes/adds/changes "useless/non-effective" modifiers -- but not always.
EDIT:
Back to the original proposal, it wouldn't even be quite as simple as just removing access modifiers. An interface may contain private/internal static members, class/interface definitions, or default method implementations. It would only be safe to remove public
modifiers. Now some people might not like the inconsistency in only showing some access modifiers and removing others. And that's a valid preference, IMO. My vote is to leave things how the dev wrote them.
from csharpier.
Having read your arguments, I probably agree that this issue is a bit beyond the scope of CSharpier's responsibility, because it can potentially change the behavior of the source code. Yes, there are many special cases here. I think it's better for the developer to make his own decision about the access modifier, depending on the situation.
Thanks for the feedback!
Closing the issue.
from csharpier.
Related Issues (20)
- Informational Window for a given file
- Incorrect formatting for simple lambda expression with comment HOT 1
- Operator placement in long if statements HOT 3
- Inconsistent formatting of linq chains
- Orphan variable since v0.27.1 HOT 1
- Don't have dedented method call if there is a long chain
- Extra newline before collection expression in attributes
- Operators expressions: keep 1st operand on 1st line? HOT 1
- using static System.* usings not ordered before other static usings like using System.* ones
- Spacing after StyleCop.Analyzers file header
- CSharper does not recognize class primary constructor HOT 2
- Spread (in collection expression) are not formatted
- Using aliases sorting is not always the same depending on the input order
- Extra indent when call method on RawStringLiteral HOT 1
- Add more options to CodeFormatterOptions HOT 1
- editorconfig dotnet_sort_system_directives_first = false ignored HOT 2
- VSCode extension support local csharpier install HOT 2
- Visual Studio stopped responding for 9 seconds. Disabling the extension CSharpier 1.5.1 might help. HOT 8
- CSharpier can not support slice[] grama, HOT 3
- Avoid wrapping method arguments including a block-bodied lambda HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from csharpier.