From 73ea4568ab277493c6717fa004cf19f9b7aae449 Mon Sep 17 00:00:00 2001
From: Evan Hemsley <evan@moonside.games>
Date: Wed, 5 Aug 2020 02:04:29 -0700
Subject: [PATCH] change Span returns to ReadOnlySpan

---
 encompass-cs/Collections/ComponentDeltaStore.cs |  2 +-
 encompass-cs/Collections/ComponentStore.cs      |  4 ++--
 encompass-cs/Collections/MessageStore.cs        |  2 +-
 encompass-cs/Collections/TypedComponentStore.cs |  8 ++++----
 encompass-cs/Collections/TypedMessageStore.cs   |  4 ++--
 encompass-cs/ComponentManager.cs                | 14 +++++++-------
 encompass-cs/Engine.cs                          |  6 +++---
 encompass-cs/MessageManager.cs                  |  2 +-
 encompass-cs/Renderer.cs                        |  4 ++--
 9 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/encompass-cs/Collections/ComponentDeltaStore.cs b/encompass-cs/Collections/ComponentDeltaStore.cs
index 48d44c4..75a3b75 100644
--- a/encompass-cs/Collections/ComponentDeltaStore.cs
+++ b/encompass-cs/Collections/ComponentDeltaStore.cs
@@ -74,7 +74,7 @@ namespace Encompass
             }
         }
 
-        public Span<Entity> AllEntities<TComponent>() where TComponent : struct
+        public ReadOnlySpan<Entity> AllEntities<TComponent>() where TComponent : struct
         {
             return _store.AllEntities<TComponent>();
         }
diff --git a/encompass-cs/Collections/ComponentStore.cs b/encompass-cs/Collections/ComponentStore.cs
index bfbc8af..986a5b0 100644
--- a/encompass-cs/Collections/ComponentStore.cs
+++ b/encompass-cs/Collections/ComponentStore.cs
@@ -113,12 +113,12 @@ namespace Encompass
             return Lookup<TComponent>().Count > 0;
         }
 
-        public Span<TComponent> All<TComponent>() where TComponent : struct
+        public ReadOnlySpan<TComponent> All<TComponent>() where TComponent : struct
         {
             return Lookup<TComponent>().AllComponents();
         }
 
-        public Span<Entity> AllEntities<TComponent>() where TComponent : struct
+        public ReadOnlySpan<Entity> AllEntities<TComponent>() where TComponent : struct
         {
             return Lookup<TComponent>().AllEntities();
         }
diff --git a/encompass-cs/Collections/MessageStore.cs b/encompass-cs/Collections/MessageStore.cs
index 3f57158..196dc7f 100644
--- a/encompass-cs/Collections/MessageStore.cs
+++ b/encompass-cs/Collections/MessageStore.cs
@@ -41,7 +41,7 @@ namespace Encompass
             return ref Lookup<TMessage>().First();
         }
 
-        public Span<TMessage> All<TMessage>() where TMessage : struct, IMessage
+        public ReadOnlySpan<TMessage> All<TMessage>() where TMessage : struct, IMessage
         {
             return Lookup<TMessage>().All();
         }
diff --git a/encompass-cs/Collections/TypedComponentStore.cs b/encompass-cs/Collections/TypedComponentStore.cs
index 232fa2b..83cd785 100644
--- a/encompass-cs/Collections/TypedComponentStore.cs
+++ b/encompass-cs/Collections/TypedComponentStore.cs
@@ -127,14 +127,14 @@ namespace Encompass
             _priorities.Clear();
         }
 
-        public Span<Entity> AllEntities()
+        public ReadOnlySpan<Entity> AllEntities()
         {
-            return new Span<Entity>(_storageIndexToEntities, 0, _nextID);
+            return new ReadOnlySpan<Entity>(_storageIndexToEntities, 0, _nextID);
         }
 
-        public Span<TComponent> AllComponents()
+        public ReadOnlySpan<TComponent> AllComponents()
         {
-            return new Span<TComponent>(_components, 0, _nextID);
+            return new ReadOnlySpan<TComponent>(_components, 0, _nextID);
         }
     }
 }
diff --git a/encompass-cs/Collections/TypedMessageStore.cs b/encompass-cs/Collections/TypedMessageStore.cs
index c8a263e..a9f222b 100644
--- a/encompass-cs/Collections/TypedMessageStore.cs
+++ b/encompass-cs/Collections/TypedMessageStore.cs
@@ -92,9 +92,9 @@ namespace Encompass
             return _nextIndex != 0;
         }
 
-        public Span<TMessage> All()
+        public ReadOnlySpan<TMessage> All()
         {
-            return new Span<TMessage>(_store, 0, _nextIndex);
+            return new ReadOnlySpan<TMessage>(_store, 0, _nextIndex);
         }
 
         public IEnumerable<TMessage> WithEntity(int entityID)
diff --git a/encompass-cs/ComponentManager.cs b/encompass-cs/ComponentManager.cs
index 49fe78d..868ba05 100644
--- a/encompass-cs/ComponentManager.cs
+++ b/encompass-cs/ComponentManager.cs
@@ -98,7 +98,7 @@ namespace Encompass
 
         // existing or immediate reads
 
-        internal Span<TComponent> ReadExistingAndImmediateComponentsByType<TComponent>() where TComponent : struct
+        internal ReadOnlySpan<TComponent> ReadExistingAndImmediateComponentsByType<TComponent>() where TComponent : struct
         {
             return _upToDateComponentStore.All<TComponent>();
         }
@@ -108,7 +108,7 @@ namespace Encompass
             return ref _upToDateComponentStore.Singular<TComponent>();
         }
 
-        internal Span<Entity> GetExistingAndImmediateEntities<TComponent>() where TComponent : struct
+        internal ReadOnlySpan<Entity> GetExistingAndImmediateEntities<TComponent>() where TComponent : struct
         {
             return _upToDateComponentStore.AllEntities<TComponent>();
         }
@@ -125,7 +125,7 @@ namespace Encompass
 
         // existing reads
 
-        internal Span<TComponent> GetExistingComponents<TComponent>() where TComponent : struct
+        internal ReadOnlySpan<TComponent> GetExistingComponents<TComponent>() where TComponent : struct
         {
             return _existingComponentStore.All<TComponent>();
         }
@@ -135,7 +135,7 @@ namespace Encompass
             return ref _existingComponentStore.Singular<TComponent>();
         }
 
-        internal Span<Entity> GetExistingEntities<TComponent>() where TComponent : struct
+        internal ReadOnlySpan<Entity> GetExistingEntities<TComponent>() where TComponent : struct
         {
             return _existingComponentStore.AllEntities<TComponent>();
         }
@@ -152,7 +152,7 @@ namespace Encompass
 
         // immediate reads
 
-        internal Span<TComponent> ReadImmediateComponentsByType<TComponent>() where TComponent : struct
+        internal ReadOnlySpan<TComponent> ReadImmediateComponentsByType<TComponent>() where TComponent : struct
         {
             return _immediateComponentStore.All<TComponent>();
         }
@@ -162,7 +162,7 @@ namespace Encompass
             return ref _immediateComponentStore.Singular<TComponent>();
         }
 
-        internal Span<Entity> GetImmediateEntities<TComponent>() where TComponent : struct
+        internal ReadOnlySpan<Entity> GetImmediateEntities<TComponent>() where TComponent : struct
         {
             return _immediateComponentStore.AllEntities<TComponent>();
         }
@@ -226,7 +226,7 @@ namespace Encompass
             return _immediateComponentStore.Has(type, entityID);
         }
 
-        internal Span<TComponent> GetComponentsByType<TComponent>() where TComponent : struct
+        internal ReadOnlySpan<TComponent> GetComponentsByType<TComponent>() where TComponent : struct
         {
             return _existingComponentStore.All<TComponent>();
         }
diff --git a/encompass-cs/Engine.cs b/encompass-cs/Engine.cs
index 548d7f6..46abe4d 100644
--- a/encompass-cs/Engine.cs
+++ b/encompass-cs/Engine.cs
@@ -223,7 +223,7 @@ namespace Encompass
         /// <summary>
         /// Returns all Entities containing the specified Component type.
         /// </summary>
-        protected Span<Entity> ReadEntities<TComponent>() where TComponent : struct, IComponent
+        protected ReadOnlySpan<Entity> ReadEntities<TComponent>() where TComponent : struct, IComponent
         {
             var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
             var existingRead = ReadTypes.Contains(typeof(TComponent));
@@ -273,7 +273,7 @@ namespace Encompass
         /// <summary>
         /// Returns all of the Components with the specified Component Type.
         /// </summary>
-        protected Span<TComponent> ReadComponents<TComponent>() where TComponent : struct, IComponent
+        protected ReadOnlySpan<TComponent> ReadComponents<TComponent>() where TComponent : struct, IComponent
         {
             var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
             var existingRead = ReadTypes.Contains(typeof(TComponent));
@@ -550,7 +550,7 @@ namespace Encompass
         /// <exception cref="Encompass.Exceptions.IllegalReadException">
         /// Thrown when the Engine does not declare that it Receives the specified Message Type.
         /// </exception>
-        protected Span<TMessage> ReadMessages<TMessage>() where TMessage : struct, IMessage
+        protected ReadOnlySpan<TMessage> ReadMessages<TMessage>() where TMessage : struct, IMessage
         {
             CheckMessageRead<TMessage>();
             return _messageManager.GetMessagesByType<TMessage>();
diff --git a/encompass-cs/MessageManager.cs b/encompass-cs/MessageManager.cs
index 234f46f..73f4c20 100644
--- a/encompass-cs/MessageManager.cs
+++ b/encompass-cs/MessageManager.cs
@@ -38,7 +38,7 @@ namespace Encompass
             _messageStore.ProcessDelayedMessages(dt * _timeManager.TimeDilationFactor, dt);
         }
 
-        internal Span<TMessage> GetMessagesByType<TMessage>() where TMessage : struct, IMessage
+        internal ReadOnlySpan<TMessage> GetMessagesByType<TMessage>() where TMessage : struct, IMessage
         {
             return _messageStore.All<TMessage>();
         }
diff --git a/encompass-cs/Renderer.cs b/encompass-cs/Renderer.cs
index 85b5489..697e377 100644
--- a/encompass-cs/Renderer.cs
+++ b/encompass-cs/Renderer.cs
@@ -18,7 +18,7 @@ namespace Encompass
             _componentManager = componentManager;
         }
 
-        protected Span<Entity> ReadEntities<TComponent>() where TComponent : struct, IComponent
+        protected ReadOnlySpan<Entity> ReadEntities<TComponent>() where TComponent : struct, IComponent
         {
             return _componentManager.GetExistingEntities<TComponent>();
         }
@@ -28,7 +28,7 @@ namespace Encompass
             return ref _componentManager.ExistingSingularEntity<TComponent>();
         }
 
-        protected Span<TComponent> ReadComponents<TComponent>() where TComponent : struct, IComponent
+        protected ReadOnlySpan<TComponent> ReadComponents<TComponent>() where TComponent : struct, IComponent
         {
             return _componentManager.GetComponentsByType<TComponent>();
         }