diff --git a/Assets/Plugins/StringFormatter/StringFormatter.cs b/Assets/Plugins/StringFormatter/StringFormatter.cs
index fbfb664..358d56c 100644
--- a/Assets/Plugins/StringFormatter/StringFormatter.cs
+++ b/Assets/Plugins/StringFormatter/StringFormatter.cs
@@ -18,20 +18,16 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
using System.Globalization;
-using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
+using UnsafeIL;
namespace System.Text.Formatting {
- ///
- /// Specifies an interface for types that act as a set of formatting arguments.
- ///
- public interface IArgSet {
+ ///
+ /// Specifies an interface for types that act as a set of formatting arguments.
+ ///
+ public interface IArgSet {
///
/// The number of arguments in the set.
///
@@ -547,37 +543,37 @@ namespace System.Text.Formatting {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void AppendGeneric(T value, StringView format) {
- // this looks gross, but T is known at JIT-time so this call tree
- // gets compiled down to a direct call with no branching
- if (typeof(T) == typeof(sbyte))
- Append(__refvalue(__makeref(value), sbyte), format);
- else if (typeof(T) == typeof(byte))
- Append(__refvalue(__makeref(value), byte), format);
- else if (typeof(T) == typeof(short))
- Append(__refvalue(__makeref(value), short), format);
- else if (typeof(T) == typeof(ushort))
- Append(__refvalue(__makeref(value), ushort), format);
- else if (typeof(T) == typeof(int))
- Append(__refvalue(__makeref(value), int), format);
- else if (typeof(T) == typeof(uint))
- Append(__refvalue(__makeref(value), uint), format);
- else if (typeof(T) == typeof(long))
- Append(__refvalue(__makeref(value), long), format);
- else if (typeof(T) == typeof(ulong))
- Append(__refvalue(__makeref(value), ulong), format);
- else if (typeof(T) == typeof(float))
- Append(__refvalue(__makeref(value), float), format);
- else if (typeof(T) == typeof(double))
- Append(__refvalue(__makeref(value), double), format);
- else if (typeof(T) == typeof(decimal))
- Append(__refvalue(__makeref(value), decimal), format);
- else if (typeof(T) == typeof(bool))
- Append(__refvalue(__makeref(value), bool));
- else if (typeof(T) == typeof(char))
- Append(__refvalue(__makeref(value), char), format);
- else if (typeof(T) == typeof(string))
- Append((string)(object)value);
- else {
+ // this looks gross, but T is known at JIT-time so this call tree
+ // gets compiled down to a direct call with no branching
+ if (typeof(T) == typeof(sbyte))
+ Append(*(sbyte*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(byte))
+ Append(*(byte*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(short))
+ Append(*(short*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(ushort))
+ Append(*(ushort*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(int))
+ Append(*(int*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(uint))
+ Append(*(uint*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(long))
+ Append(*(long*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(ulong))
+ Append(*(ulong*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(float))
+ Append(*(float*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(double))
+ Append(*(double*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(decimal))
+ Append(*(decimal*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(bool))
+ Append(*(bool*)Unsafe.AsPointer(ref value));
+ else if (typeof(T) == typeof(char))
+ Append(*(char*)Unsafe.AsPointer(ref value), format);
+ else if (typeof(T) == typeof(string))
+ Append(Unsafe.As(value));
+ else {
// first, check to see if it's a value type implementing IStringFormattable
var formatter = ValueHelper.Formatter;
if (formatter != null)
diff --git a/Assets/Plugins/UnsafeIL.dll b/Assets/Plugins/UnsafeIL.dll
new file mode 100644
index 0000000..4b385a3
Binary files /dev/null and b/Assets/Plugins/UnsafeIL.dll differ
diff --git a/Assets/Plugins/UnsafeIL.dll.meta b/Assets/Plugins/UnsafeIL.dll.meta
new file mode 100644
index 0000000..4f9af62
--- /dev/null
+++ b/Assets/Plugins/UnsafeIL.dll.meta
@@ -0,0 +1,33 @@
+fileFormatVersion: 2
+guid: d927992f95b82f740a0a95bb6d617d73
+PluginImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ iconMap: {}
+ executionOrder: {}
+ defineConstraints: []
+ isPreloaded: 0
+ isOverridable: 0
+ isExplicitlyReferenced: 0
+ validateReferences: 1
+ platformData:
+ - first:
+ Any:
+ second:
+ enabled: 1
+ settings: {}
+ - first:
+ Editor: Editor
+ second:
+ enabled: 0
+ settings:
+ DefaultValueInitialized: true
+ - first:
+ Windows Store Apps: WindowsStoreApps
+ second:
+ enabled: 0
+ settings:
+ CPU: AnyCPU
+ userData:
+ assetBundleName:
+ assetBundleVariant: