down with compatibility shims!

This commit is contained in:
Brendan Forster
2013-10-31 15:01:31 +11:00
parent cb20475144
commit db2fae206c
6 changed files with 5 additions and 122 deletions

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
namespace Octokit.Reactive namespace Octokit.Reactive

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Reactive.Threading.Tasks; using System.Reactive.Threading.Tasks;
namespace Octokit.Reactive namespace Octokit.Reactive

View File

@@ -1,6 +1,4 @@
#if NETFX_CORE using System.Collections.Generic;
using System.Collections.Generic;
#endif
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Octokit namespace Octokit

View File

@@ -1,6 +1,4 @@
#if NETFX_CORE using System.Collections.Generic;
using System.Collections.Generic;
#endif
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Octokit namespace Octokit

View File

@@ -1,114 +0,0 @@
// ----------------------------------------------------
// THIS WHOLE File CAN GO AWAY WHEN WE TARGET 4.5 ONLY
// ----------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace Octokit
{
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
[SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
public interface IReadOnlyDictionary<TKey, TValue> : IReadOnlyCollection<KeyValuePair<TKey, TValue>>
{
bool ContainsKey(TKey key);
bool TryGetValue(TKey key, out TValue value);
TValue this[TKey key] { get; }
IEnumerable<TKey> Keys { get; }
IEnumerable<TValue> Values { get; }
}
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public interface IReadOnlyList<out TItem> : IReadOnlyCollection<TItem>
{
TItem this[int index] { get; }
}
public interface IReadOnlyCollection<out T> : IEnumerable<T>
{
int Count { get; }
}
public class ReadOnlyCollection<TItem> : IReadOnlyList<TItem>
{
readonly List<TItem> _source;
public ReadOnlyCollection(IList<TItem> source)
{
_source = new List<TItem>(source);
}
public IEnumerator<TItem> GetEnumerator()
{
return _source.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public int Count
{
get { return _source.Count; }
}
public TItem this[int index]
{
get { return _source[index]; }
}
}
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
[SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
public class ReadOnlyDictionary<TKey, TValue> : IReadOnlyDictionary<TKey, TValue>
{
readonly IDictionary<TKey, TValue> _source;
public ReadOnlyDictionary(IDictionary<TKey, TValue> source)
{
_source = new Dictionary<TKey, TValue>(source);
}
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
{
return _source.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public int Count
{
get { return _source.Count; }
}
public bool ContainsKey(TKey key)
{
return _source.ContainsKey(key);
}
public bool TryGetValue(TKey key, out TValue value)
{
return _source.TryGetValue(key, out value);
}
public TValue this[TKey key]
{
get { return _source[key]; }
}
public IEnumerable<TKey> Keys
{
get { return _source.Keys; }
}
public IEnumerable<TValue> Values
{
get { return _source.Values; }
}
}
}

View File

@@ -117,7 +117,6 @@
<Compile Include="Exceptions\LoginAttemptsExceededException.cs" /> <Compile Include="Exceptions\LoginAttemptsExceededException.cs" />
<Compile Include="Exceptions\RateLimitExceededException.cs" /> <Compile Include="Exceptions\RateLimitExceededException.cs" />
<Compile Include="Helpers\CollectionExtensions.cs" /> <Compile Include="Helpers\CollectionExtensions.cs" />
<Compile Include="Helpers\Net45CompatibilityShim.cs" />
<Compile Include="Helpers\UriExtensions.cs" /> <Compile Include="Helpers\UriExtensions.cs" />
<Compile Include="Http\ApiConnection.cs" /> <Compile Include="Http\ApiConnection.cs" />
<Compile Include="Http\IApiConnection.cs" /> <Compile Include="Http\IApiConnection.cs" />