Comments (9)
There should be a fix offered here.
from roslyn.
The warning is correct, you can do this:
Orientation orientation = (Orientation)3;
from roslyn.
@jjonescz: You could also do anything that's valid for an integer. Yet, who would do that?
I don't think it's reasonable to warn about hypothetical assignments. It would make more sense to warn about assigning invalid values to an enum type.
from roslyn.
I don't think it's reasonable to warn about hypothetical assignments.
In that case you should suppress the warning for your whole project or solution.
It would make more sense to warn about assigning invalid values to an enum type.
There might be an analyzer for that. But it's an explicit cast, so it should be obvious you are doing something advanced and warning doesn't seem necessary.
Otherwise this is a language design question, those should be discussed in https://github.com/dotnet/csharplang first. Thanks!
from roslyn.
With all due respect, the current warning text doesn't make any sense to this regard.
In the end, it all boils down to "add an anonymous switch case". Period. Nothing else.
Anything else, like the current "you are missing this or that value" endlessly is just a ridiculous cat-and-mouse game. You would end up adding 32768 switch cases.
Have you ever thought about providing a quick fix for remedying this warning by adding all the corresponding switch cases? The current warning message ("you are missing a particular value") is plain nonsense.
from roslyn.
re-open for IDE fixer
from roslyn.
New feature/Temp put under Sam's bucket because it's related to CodeStyle.
from roslyn.
@CyrusNajmabadi It seems like the fix here is project specific. For example, in Roslyn the fix would be throwing ExceptionUtilities.UnexpectedValue
, but that method doesn't exist generally.
from roslyn.
After reviewing the SharpLab output for the original code sample, I'm doubting our ability to improve upon the current behavior. Before implementing a code fix, I would need to see a proposed code fix that achieves the following:
- The performance matches the current behavior (the exception is thrown from a different method, or the use of a throw helper is known to no longer provide specific value)
- The exception type and message is of similar quality to the current one
- The clarity of the switch expression is not negatively impacted
from roslyn.
Related Issues (20)
- Debug assert triggered for interpolated string convserion
- "dotnet build-server shutdown" warning for missing dll HOT 3
- Enabling latest-All analyzers hangs build
- TestCode classification breaks in LSP for lines that begin with whitespace
- See squigglies in #if'd code but Quick Actions don't work. HOT 1
- Method name style is not consistent along the code HOT 1
- EnC: Emit System.Runtime.CompilerServices.HotReloadException
- Go to definition is not consistent with C# compilation when a symbol is missing HOT 8
- Auto-indent doesn't work in inline diff mode HOT 1
- $$ in source code causes test always to fail
- Nonsense identifier expected error depending on how you edit unrelated code HOT 1
- [Automated] PRs inserted in VS build feature.debugger.main-35118.200
- [Automated] PRs inserted in VS build main-35118.130
- IDE0270 creates invalid code HOT 2
- NuGet packages need to include a README.md HOT 2
- Code action "Allow unsafe code in this project" has no effect HOT 2
- Adding `_` (discard) in front of evaluation auto-completes to first symbol name match for `_` (underscore) HOT 3
- Renaming a global using alias does not update usages
- Visual Studio insists on autocorrecting the method name I type to a similarly named field HOT 3
- Incorrect "Nullability doesn't match the target delegate" when tuple element names don't explicitly match
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 roslyn.