Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IEnumerable implementation on String with exception throwing. #114

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion nanoFramework.CoreLibrary/System/String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace System
{
using Runtime.CompilerServices;
using System.Collections;
/// <summary>
/// Represents text as a sequence of UTF-16 code units.
/// </summary>
Expand All @@ -17,11 +18,26 @@ namespace System
// GetHashCode() implementation is provided by general native function CLR_RT_HeapBlock::GetHashCode //
///////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma warning disable S1206 // "Equals(Object)" and "GetHashCode()" should be overridden in pairs
public sealed class String : IComparable
public sealed class String : IComparable, IEnumerable
#pragma warning restore S1206 // "Equals(Object)" and "GetHashCode()" should be overridden in pairs
#pragma warning restore CS0661 // Type defines operator == or operator != but does not override Object.GetHashCode()
#pragma warning restore CS0659 // Type overrides Object.Equals(object o) but does not override Object.GetHashCode()
{
/// <summary>
/// **Not supported in NanoFramework**
/// Return an enumerator that iterate on each char of the string.
/// </summary>
/// <returns>An IEnumerator object that can be used to iterate through the collection.</returns>
public IEnumerator GetEnumerator()
{
// Not implemented because of assembly size constraint
// Throw a NotSupportedException in compliance of .net practices
// (no message to preserve assembly size/memory consumption)
// See https://docs.microsoft.com/en-us/dotnet/api/system.notsupportedexception
throw new NotSupportedException();
}


/// <summary>
/// Represents the empty string. This field is read-only.
/// </summary>
Expand Down Expand Up @@ -64,6 +80,9 @@ public override bool Equals(object obj)
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern bool operator !=(String a, String b);




/// <summary>
/// Gets the Char object at a specified position in the current String object.
/// </summary>
Expand Down