Comments (4)
@oruchreis, thanks for reporting this.
The collection expression conversion requires each element in the collection to be implicitly convertible to the iteration type of the target type. Previously, the compiler ignored the strongly-typed GetEnumerator()
implementation and assumed the iteration type of a type implementing IEnumerable
only is object
(rather than (string, uint)
in this case) and that all elements were implicitly convertible to object
.
Sorry for the inconvenience.
from roslyn.
@cston But the element item is not (string, uint)
, it is object
in this case, The class is IEnumerable
and not IEnumerable<(string, uint)>
.
public class IpList : IEnumerable //<<
{
The IEnumerator<(string, uint)> GetEnumerator()
method is not belong to IEnumerable
interface. Shouldn't the compiler not recognise this method as part of IEnumerable
? Anyway, this method does not belong to IEnumerable
. So the collection expression is applied to a class that implements IEnumerable
, not to a class that is IEnumerable<(string, uint)
.
from roslyn.
The iteration type used by collection expression conversions is the foreach statement iteration type which prefers the signature of the accessible GetEnumerator()
method, if any, over the interface. It was an oversight that the compiler ignored the accessible GetEnumerator()
method previously for the conversion and simply relied on the interface.
from roslyn.
Closing as the new behavior is "By Design".
from roslyn.
Related Issues (20)
- constant string allow conversions HOT 1
- Out parameter on Dictionary<TKey, TValue>.TryGetValue(TKey, out TValue) is flagged by IDE0008 when it shouldn't be
- Erroneous CS0266 on 'byte = byte & byte' HOT 4
- [Automated] PRs inserted in VS build main-35112.83
- IEventSymbol.DeclaringSyntaxReferences Syntax is VariableDeclaratorSyntax not EventFieldDeclarationSyntax HOT 1
- Visual Studio 2022 error list doesn't show errors from build failures in Build + Intellisense view
- IDE1006: Naming rule violation: Prefix 's_' is not expected after upgrading to .NET 9 SDK
- Parameter info/signature help session won't start
- Reference highlight doesn't highlight references/usages of type aliases
- implicit `return 0` for <top-level-statements-entry-point> HOT 1
- `ref` modifier keyword is missing from completions for `ref struct` primary constructor parameter definition
- Source Generator generated code cannot be compiled HOT 10
- Check if ModuleCancellationInstrumenter gracefully handles ref kind differences between original and replacement methods HOT 1
- Saving an AdditionalFiles document in Balanced mode fails to trigger source generator HOT 1
- Tests failing with BadImageFormatException
- [Automated] PRs inserted in VS build main-35115.160
- Name of ```AllowedRequiredModifierType.System_Runtime_CompilerServices_OutAttribute``` implies wrong location of the ```OutAttribute``` type
- Generic extension method on generic type with `LangVersion=preview` and `Nullable=enable` crashes compiler with `NullReferenceException` in `ConstraintsHelper.CheckConstraints` when accessing non-existent member of extension method's name on type
- MSBuildWorkspace should have unit tests running on mono
- error RZ3600: Invalid value ''' for RazorLangVersion. Valid values include 'Latest' or a valid version in range 1 .0 to 8.0 HOT 8
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.