Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Commit

Permalink
Maintenance (#5)
Browse files Browse the repository at this point in the history
- Fixes bugs
- Fixes comments(typos)
- Rename namespace and DLL (UnsafeGeneric -> Better.UnsafeGeneric)
- Add  Microsoft.Net.Compilers(2.4.0) to avoid generating conv.u instruction
  • Loading branch information
troubear authored Dec 20, 2018
1 parent cd0c267 commit 904c551
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 31 deletions.
Binary file not shown.
8 changes: 4 additions & 4 deletions Assets/Plugins/BetterDictionary/EqualityComparerFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using UnsafeGeneric;
using Better.UnsafeGeneric;

namespace Better
{
Expand Down Expand Up @@ -44,18 +44,18 @@ public static IEqualityComparer<T> Create<T>()
{
return (IEqualityComparer<T>)StringKeyEqualityComparer;
}
return null; // float, double, structs
return null; // Use default EqualityComparer
}
}

/// <summary>
/// An implementation of <see cref="IEqualityComparer{T}" /> for the <see cref="StringKey" /> type.
/// </summary>
internal struct StringKeyEqualityComparer : IEqualityComparer<StringKey>
class StringKeyEqualityComparer : IEqualityComparer<StringKey>
{
public bool Equals(StringKey x, StringKey y)
{
return x.Equals(y);
return string.Equals(x.Value, y.Value);
}

public int GetHashCode(StringKey obj)
Expand Down
11 changes: 5 additions & 6 deletions Assets/Plugins/BetterDictionary/StringKey.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using UnsafeGeneric;
using Better.UnsafeGeneric;

#if !BETTER_PATCH
namespace Better
Expand Down Expand Up @@ -28,7 +28,7 @@ public StringKey(string str)

public bool Equals(StringKey key)
{
return Value.Equals(key.Value);
return string.Equals(Value, key.Value);
}

public override bool Equals(object obj)
Expand All @@ -38,8 +38,7 @@ public override bool Equals(object obj)
return Equals((StringKey)obj);
}

// exception will be thrown later for null this
return this == null;
return false;
}

public override int GetHashCode()
Expand All @@ -49,12 +48,12 @@ public override int GetHashCode()

public static bool operator ==(StringKey a, StringKey b)
{
return a.Equals(b);
return a.HashCode == b.HashCode && a.Value == b.Value;
}

public static bool operator !=(StringKey a, StringKey b)
{
return !a.Equals(b);
return a.HashCode != b.HashCode || a.Value != b.Value;
}

// StringKey key = "Foo";
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
m_EditorVersion: 5.6.4f1
m_EditorVersion: 5.6.6f2
18 changes: 9 additions & 9 deletions UnsafeGeneric.Build/EqualityComparers.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace UnsafeGeneric
namespace Better.UnsafeGeneric
{
/// <summary>
/// An implementation of <see cref="IEqualityComparer{T}" /> for 32 bit signed integer types.
/// </summary>
/// <typeparam name="T">The interger type to compare.</typeparam>
public struct Int32EqualityComparer<T> : IEqualityComparer<T>
/// <typeparam name="T">The integer type to compare.</typeparam>
public sealed class Int32EqualityComparer<T> : IEqualityComparer<T>
{
[MethodImpl(MethodImplOptions.ForwardRef)]
public extern bool Equals(T x, T y);
Expand All @@ -19,8 +19,8 @@ public struct Int32EqualityComparer<T> : IEqualityComparer<T>
/// <summary>
/// An implementation of <see cref="IEqualityComparer{T}" /> for 64 bit signed integer types.
/// </summary>
/// <typeparam name="T">The interger type to compare.</typeparam>
public struct Int64EqualityComparer<T> : IEqualityComparer<T>
/// <typeparam name="T">The integer type to compare.</typeparam>
public sealed class Int64EqualityComparer<T> : IEqualityComparer<T>
{
[MethodImpl(MethodImplOptions.ForwardRef)]
public extern bool Equals(T x, T y);
Expand All @@ -32,8 +32,8 @@ public struct Int64EqualityComparer<T> : IEqualityComparer<T>
/// <summary>
/// An implementation of <see cref="IEqualityComparer{T}" /> for 64 bit unsigned integer types.
/// </summary>
/// <typeparam name="T">The interger type to compare.</typeparam>
public struct UInt64EqualityComparer<T> : IEqualityComparer<T>
/// <typeparam name="T">The integer type to compare.</typeparam>
public sealed class UInt64EqualityComparer<T> : IEqualityComparer<T>
{
[MethodImpl(MethodImplOptions.ForwardRef)]
public extern bool Equals(T x, T y);
Expand All @@ -45,11 +45,11 @@ public struct UInt64EqualityComparer<T> : IEqualityComparer<T>
/// <summary>
/// An implementation of <see cref="IEqualityComparer{T}" /> for the string type.
/// </summary>
public struct StringEqualityComparer : IEqualityComparer<string>
public sealed class StringEqualityComparer : IEqualityComparer<string>
{
public bool Equals(string x, string y)
{
return x.Equals(y);
return string.Equals(x, y);
}

public int GetHashCode(string obj)
Expand Down
6 changes: 3 additions & 3 deletions UnsafeGeneric.Build/EqualityComparers.il
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Int32EqualityComparer<T>
.class private sealed sequential ansi beforefieldinit
UnsafeGeneric.Int32EqualityComparer`1<T>
Better.UnsafeGeneric.Int32EqualityComparer`1<T>
extends [mscorlib]System.ValueType
implements class [mscorlib]System.Collections.Generic.IEqualityComparer`1<!0/*T*/>
{
Expand Down Expand Up @@ -28,7 +28,7 @@

// Int64EqualityComparer<T>
.class private sealed sequential ansi beforefieldinit
UnsafeGeneric.Int64EqualityComparer`1<T>
Better.UnsafeGeneric.Int64EqualityComparer`1<T>
extends [mscorlib]System.ValueType
implements class [mscorlib]System.Collections.Generic.IEqualityComparer`1<!0/*T*/>
{
Expand Down Expand Up @@ -63,7 +63,7 @@

// UInt64EqualityComparer<T>
.class private sealed sequential ansi beforefieldinit
UnsafeGeneric.UInt64EqualityComparer`1<T>
Better.UnsafeGeneric.UInt64EqualityComparer`1<T>
extends [mscorlib]System.ValueType
implements class [mscorlib]System.Collections.Generic.IEqualityComparer`1<!0/*T*/>
{
Expand Down
10 changes: 5 additions & 5 deletions UnsafeGeneric.Build/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("System.Collections.UnsafeGeneric")]
[assembly: AssemblyTitle("Better.UnsafeGeneric")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("System.Collections.UnsafeGeneric")]
[assembly: AssemblyCopyright("Copyright © 2017 Takuma Komatsu")]
[assembly: AssemblyProduct("Better.UnsafeGeneric")]
[assembly: AssemblyCopyright("Copyright © 2018 Takuma Komatsu")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
2 changes: 1 addition & 1 deletion UnsafeGeneric.Build/StringHashCode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace UnsafeGeneric
namespace Better.UnsafeGeneric
{
/// <summary>
/// Provides the string hash code calculation method.
Expand Down
16 changes: 14 additions & 2 deletions UnsafeGeneric.Build/UnsafeGeneric.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props" Condition="Exists('packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B7DA5C28-CDA4-4E3F-9AE2-DF2A123CB240}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UnsafeGeneric</RootNamespace>
<AssemblyName>UnsafeGeneric</AssemblyName>
<RootNamespace>Better.UnsafeGeneric</RootNamespace>
<AssemblyName>Better.UnsafeGeneric</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -45,6 +48,9 @@
<Compile Include="EqualityComparers.il" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<CompileDependsOn>
Expand Down Expand Up @@ -154,6 +160,12 @@
</ItemGroup>
<Touch Files="$(ILFile)" />
</Target>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>このプロジェクトは、このコンピューター上にない NuGet パッケージを参照しています。それらのパッケージをダウンロードするには、[NuGet パッケージの復元] を使用します。詳細については、http://go.microsoft.com/fwlink/?LinkID=322105 を参照してください。見つからないファイルは {0} です。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
4 changes: 4 additions & 0 deletions UnsafeGeneric.Build/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Net.Compilers" version="2.4.0" targetFramework="net35" developmentDependency="true" />
</packages>

0 comments on commit 904c551

Please sign in to comment.