Skip to content

Commit

Permalink
Add IEnumerable implementation on String with exception throwing. (#114)
Browse files Browse the repository at this point in the history
***NO_CI***
  • Loading branch information
flyingoverclouds authored Nov 16, 2020
1 parent bdc5c79 commit 5ac417b
Showing 1 changed file with 20 additions and 1 deletion.
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

0 comments on commit 5ac417b

Please sign in to comment.