Merge pull request #1381 from paulpach/reformat

refactor: cleanup code format using dotnet-format
This commit is contained in:
vis2k 2020-01-01 09:19:54 +01:00 committed by GitHub
commit fd0e2b18c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 176 additions and 163 deletions

View File

@ -31,14 +31,14 @@ public Styles()
{
Color fontColor = new Color(0.7f, 0.7f, 0.7f);
labelStyle.padding.right += 20;
labelStyle.normal.textColor = fontColor;
labelStyle.active.textColor = fontColor;
labelStyle.focused.textColor = fontColor;
labelStyle.hover.textColor = fontColor;
labelStyle.onNormal.textColor = fontColor;
labelStyle.onActive.textColor = fontColor;
labelStyle.normal.textColor = fontColor;
labelStyle.active.textColor = fontColor;
labelStyle.focused.textColor = fontColor;
labelStyle.hover.textColor = fontColor;
labelStyle.onNormal.textColor = fontColor;
labelStyle.onActive.textColor = fontColor;
labelStyle.onFocused.textColor = fontColor;
labelStyle.onHover.textColor = fontColor;
labelStyle.onHover.textColor = fontColor;
componentName.normal.textColor = fontColor;
componentName.active.textColor = fontColor;

View File

@ -59,18 +59,18 @@ public static void OnPostProcessScene()
identity.gameObject.SetActive(false);
// safety check for prefabs with more than one NetworkIdentity
#if UNITY_2018_2_OR_NEWER
#if UNITY_2018_2_OR_NEWER
GameObject prefabGO = PrefabUtility.GetCorrespondingObjectFromSource(identity.gameObject) as GameObject;
#else
#else
GameObject prefabGO = PrefabUtility.GetPrefabParent(identity.gameObject) as GameObject;
#endif
#endif
if (prefabGO)
{
#if UNITY_2018_3_OR_NEWER
#if UNITY_2018_3_OR_NEWER
GameObject prefabRootGO = prefabGO.transform.root.gameObject;
#else
#else
GameObject prefabRootGO = PrefabUtility.FindPrefabRoot(prefabGO);
#endif
#endif
if (prefabRootGO)
{
if (prefabRootGO.GetComponentsInChildren<NetworkIdentity>().Length > 1)

View File

@ -50,7 +50,7 @@ static void OnInitializeOnLoad()
// We only need to run this once per session
// after that, all assemblies will be weaved by the event
if (!SessionState.GetBool("MIRROR_WEAVED", false) )
if (!SessionState.GetBool("MIRROR_WEAVED", false))
{
SessionState.SetBool("MIRROR_WEAVED", true);
WeaveExisingAssemblies();

View File

@ -31,7 +31,7 @@ public static void Process(TypeDefinition td)
static void GenerateSerialization(TypeDefinition td)
{
Weaver.DLog(td, " GenerateSerialization");
MethodDefinition existingMethod = td.Methods.FirstOrDefault(md=>md.Name == "Serialize");
MethodDefinition existingMethod = td.Methods.FirstOrDefault(md => md.Name == "Serialize");
if (existingMethod != null && !existingMethod.Body.IsEmptyDefault())
{
return;
@ -108,7 +108,7 @@ static void GenerateSerialization(TypeDefinition td)
static void GenerateDeSerialization(TypeDefinition td)
{
Weaver.DLog(td, " GenerateDeserialization");
MethodDefinition existingMethod = td.Methods.FirstOrDefault(md=>md.Name == "Deserialize");
MethodDefinition existingMethod = td.Methods.FirstOrDefault(md => md.Name == "Deserialize");
if (existingMethod != null && !existingMethod.Body.IsEmptyDefault())
{
return;
@ -119,7 +119,7 @@ static void GenerateDeSerialization(TypeDefinition td)
return;
}
MethodDefinition serializeFunc = existingMethod??new MethodDefinition("Deserialize",
MethodDefinition serializeFunc = existingMethod ?? new MethodDefinition("Deserialize",
MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig,
Weaver.voidType);

View File

@ -132,7 +132,7 @@ public static bool WriteArguments(ILProcessor worker, MethodDefinition md, bool
MethodReference writeFunc = Writers.GetWriteFunc(pd.ParameterType);
if (writeFunc == null)
{
Weaver.Error($"{md} has invalid parameter {pd}" );
Weaver.Error($"{md} has invalid parameter {pd}");
return false;
}
// use built-in writer func on writer object

View File

@ -82,7 +82,7 @@ static void ProcessSiteMethod(TypeDefinition td, MethodDefinition md)
}
}
for (int iCount= 0; iCount < md.Body.Instructions.Count;)
for (int iCount = 0; iCount < md.Body.Instructions.Count;)
{
Instruction instr = md.Body.Instructions[iCount];
iCount += ProcessInstruction(md, instr, iCount);

View File

@ -24,7 +24,7 @@ public static void ProcessReadersAndWriters(AssemblyDefinition CurrentAssembly)
ProcessAssemblyClasses(CurrentAssembly, assembly);
}
}
catch(FileNotFoundException)
catch (FileNotFoundException)
{
// During first import, this gets called before some assemblies
// are built, just skip them

View File

@ -59,7 +59,7 @@ correctly in dependent assemblies
*/
public static MethodDefinition ProcessRpcCall(TypeDefinition td, MethodDefinition md, CustomAttribute ca)
{
MethodDefinition rpc = new MethodDefinition("Call" + md.Name, MethodAttributes.Public |
MethodDefinition rpc = new MethodDefinition("Call" + md.Name, MethodAttributes.Public |
MethodAttributes.HideBySig,
Weaver.voidType);

View File

@ -66,7 +66,7 @@ public static MethodDefinition ProcessEventInvoke(TypeDefinition td, EventDefini
public static MethodDefinition ProcessEventCall(TypeDefinition td, EventDefinition ed, CustomAttribute ca)
{
MethodReference invoke = Resolvers.ResolveMethod(ed.EventType, Weaver.CurrentAssembly, "Invoke");
MethodDefinition evt = new MethodDefinition("Call" + ed.Name, MethodAttributes.Public |
MethodDefinition evt = new MethodDefinition("Call" + ed.Name, MethodAttributes.Public |
MethodAttributes.HideBySig,
Weaver.voidType);
// add paramters

View File

@ -41,7 +41,7 @@ public static bool CheckForHookFunction(TypeDefinition td, FieldDefinition syncV
return false;
}
}
Weaver.Error($"No hook implementation found for {syncVar}. Add this method to your class:\npublic void {hookFunctionName}({syncVar.FieldType} value) {{ }}" );
Weaver.Error($"No hook implementation found for {syncVar}. Add this method to your class:\npublic void {hookFunctionName}({syncVar.FieldType} value) {{ }}");
return false;
}
}
@ -253,7 +253,8 @@ public static void ProcessSyncVar(TypeDefinition td, FieldDefinition fd, Diction
//create the property
PropertyDefinition propertyDefinition = new PropertyDefinition("Network" + originalName, PropertyAttributes.None, fd.FieldType)
{
GetMethod = get, SetMethod = set
GetMethod = get,
SetMethod = set
};
//add the methods and property to the type.

View File

@ -87,7 +87,7 @@ correctly in dependent assemblies
*/
public static MethodDefinition ProcessTargetRpcCall(TypeDefinition td, MethodDefinition md, CustomAttribute ca)
{
MethodDefinition rpc = new MethodDefinition("Call" + md.Name, MethodAttributes.Public |
MethodDefinition rpc = new MethodDefinition("Call" + md.Name, MethodAttributes.Public |
MethodAttributes.HideBySig,
Weaver.voidType);

View File

@ -17,7 +17,7 @@ public void SetHostname(string hostname)
public ChatWindow chatWindow;
public class CreatePlayerMessage: MessageBase
public class CreatePlayerMessage : MessageBase
{
public string name;
}

View File

@ -246,7 +246,7 @@ public static void BalancePrefabs(GameObject prefab, int amount, Transform paren
// delete everything that's too much
// (backwards loop because Destroy changes childCount)
for (int i = parent.childCount-1; i >= amount; --i)
for (int i = parent.childCount - 1; i >= amount; --i)
Destroy(parent.GetChild(i).gameObject);
}
@ -289,7 +289,8 @@ void OnUI()
slot.joinButton.interactable = !IsConnecting();
slot.joinButton.gameObject.SetActive(server.players < server.capacity);
slot.joinButton.onClick.RemoveAllListeners();
slot.joinButton.onClick.AddListener(() => {
slot.joinButton.onClick.AddListener(() =>
{
NetworkManager.singleton.networkAddress = server.ip;
NetworkManager.singleton.StartClient();
});
@ -298,13 +299,15 @@ void OnUI()
// server buttons
serverAndPlayButton.interactable = !IsConnecting();
serverAndPlayButton.onClick.RemoveAllListeners();
serverAndPlayButton.onClick.AddListener(() => {
serverAndPlayButton.onClick.AddListener(() =>
{
NetworkManager.singleton.StartHost();
});
serverOnlyButton.interactable = !IsConnecting();
serverOnlyButton.onClick.RemoveAllListeners();
serverOnlyButton.onClick.AddListener(() => {
serverOnlyButton.onClick.AddListener(() =>
{
NetworkManager.singleton.StartServer();
});
}

View File

@ -5,7 +5,7 @@ namespace Mirror.Examples.NetworkRoom
[RequireComponent(typeof(RandomColor))]
public class Reward : NetworkBehaviour
{
public bool available = true;
public bool available = true;
public Spawner spawner;
uint points;

View File

@ -14,7 +14,7 @@ public static byte ScaleFloatToByte(float value, float minValue, float maxValue,
int targetRange = maxTarget - minTarget; // max byte - min byte only fits into something bigger
float valueRange = maxValue - minValue;
float valueRelative = value - minValue;
return (byte)(minTarget + (byte)(valueRelative/valueRange * targetRange));
return (byte)(minTarget + (byte)(valueRelative / valueRange * targetRange));
}
// ScaleByteToFloat( 0, byte.MinValue, byte.MaxValue, -1, 1) => -1

View File

@ -10,7 +10,7 @@ class ULocalConnectionToClient : NetworkConnectionToClient
{
internal ULocalConnectionToServer connectionToServer;
public ULocalConnectionToClient() : base (0)
public ULocalConnectionToClient() : base(0)
{
}

View File

@ -145,7 +145,7 @@ public override void Serialize(NetworkWriter writer) { }
#endregion
#region Public System Messages
public struct ErrorMessage : IMessageBase
public struct ErrorMessage : IMessageBase
{
public byte value;

View File

@ -35,7 +35,7 @@ public abstract class NetworkAuthenticator : MonoBehaviour
/// Called on server from StartServer to initialize the Authenticator
/// <para>Server message handlers should be registered in this method.</para>
/// </summary>
public virtual void OnStartServer() {}
public virtual void OnStartServer() { }
// This will get more code in the near future
internal void OnServerAuthenticateInternal(NetworkConnection conn)
@ -57,7 +57,7 @@ internal void OnServerAuthenticateInternal(NetworkConnection conn)
/// Called on client from StartClient to initialize the Authenticator
/// <para>Client message handlers should be registered in this method.</para>
/// </summary>
public virtual void OnStartClient() {}
public virtual void OnStartClient() { }
// This will get more code in the near future
internal void OnClientAuthenticateInternal(NetworkConnection conn)

View File

@ -756,39 +756,39 @@ void DeSerializeObjectsDelta(NetworkReader reader)
/// <para>This can be used as a hook to invoke effects or do client specific cleanup.</para>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual void OnNetworkDestroy() {}
public virtual void OnNetworkDestroy() { }
/// <summary>
/// This is invoked for NetworkBehaviour objects when they become active on the server.
/// <para>This could be triggered by NetworkServer.Listen() for objects in the scene, or by NetworkServer.Spawn() for objects that are dynamically created.</para>
/// <para>This will be called for objects on a "host" as well as for object on a dedicated server.</para>
/// </summary>
public virtual void OnStartServer() {}
public virtual void OnStartServer() { }
/// <summary>
/// Called on every NetworkBehaviour when it is activated on a client.
/// <para>Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.</para>
/// </summary>
public virtual void OnStartClient() {}
public virtual void OnStartClient() { }
/// <summary>
/// Called when the local player object has been set up.
/// <para>This happens after OnStartClient(), as it is triggered by an ownership message from the server. This is an appropriate place to activate components or functionality that should only be active for the local player, such as cameras and input.</para>
/// </summary>
public virtual void OnStartLocalPlayer() {}
public virtual void OnStartLocalPlayer() { }
/// <summary>
/// This is invoked on behaviours that have authority, based on context and <see cref="NetworkIdentity.hasAuthority">NetworkIdentity.hasAuthority</see>.
/// <para>This is called after <see cref="OnStartServer">OnStartServer</see> and before <see cref="OnStartClient">OnStartClient.</see></para>
/// <para>When <see cref="NetworkIdentity.AssignClientAuthority"/> is called on the server, this will be called on the client that owns the object. When an object is spawned with <see cref="NetworkServer.Spawn">NetworkServer.Spawn</see> with a NetworkConnection parameter included, this will be called on the client that owns the object.</para>
/// </summary>
public virtual void OnStartAuthority() {}
public virtual void OnStartAuthority() { }
/// <summary>
/// This is invoked on behaviours when authority is removed.
/// <para>When NetworkIdentity.RemoveClientAuthority is called on the server, this will be called on the client that owns the object.</para>
/// </summary>
public virtual void OnStopAuthority() {}
public virtual void OnStopAuthority() { }
/// <summary>
/// Callback used by the visibility system to (re)construct the set of observers that can see this object.
@ -803,14 +803,14 @@ public virtual bool OnRebuildObservers(HashSet<NetworkConnection> observers, boo
}
[Obsolete("Rename to OnSetHostVisibility instead.")]
public virtual void OnSetLocalVisibility(bool visible) {}
public virtual void OnSetLocalVisibility(bool visible) { }
/// <summary>
/// Callback used by the visibility system for objects on a host.
/// <para>Objects on a host (with a local client) cannot be disabled or destroyed when they are not visibile to the local client. So this function is called to allow custom code to hide these objects. A typical implementation will disable renderer components on the object. This is only called on local clients on a host.</para>
/// </summary>
/// <param name="visible">New visibility state.</param>
public virtual void OnSetHostVisibility(bool visible) {}
public virtual void OnSetHostVisibility(bool visible) { }
/// <summary>
/// Callback used by the visibility system to determine if an observer (player) can see this object.

View File

@ -418,7 +418,7 @@ public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handl
/// <param name="requireAuthentication">true if the message requires an authenticated connection</param>
public static void RegisterHandler<T>(Action<T> handler, bool requireAuthentication = true) where T : IMessageBase, new()
{
RegisterHandler( (NetworkConnection _, T value) => { handler(value); }, requireAuthentication) ;
RegisterHandler((NetworkConnection _, T value) => { handler(value); }, requireAuthentication);
}
/// <summary>

View File

@ -62,7 +62,7 @@ public sealed class NetworkIdentity : MonoBehaviour
/// <summary>
/// Returns true if NetworkServer.active and server is not stopped.
/// </summary>
public bool isServer => NetworkServer.active && netId != 0;
public bool isServer => NetworkServer.active && netId != 0;
/// <summary>
/// This returns true if this object is the one that represents the player on the local machine.

View File

@ -717,7 +717,7 @@ public virtual void ServerChangeScene(string newSceneName)
loadingSceneAsync = SceneManager.LoadSceneAsync(newSceneName);
// notify all clients about the new scene
NetworkServer.SendToAll(new SceneMessage{sceneName=newSceneName});
NetworkServer.SendToAll(new SceneMessage { sceneName = newSceneName });
startPositionIndex = 0;
startPositions.Clear();

View File

@ -212,7 +212,7 @@ internal static void ActivateLocalClientScene()
// this is like SendToReady - but it doesn't check the ready flag on the connection.
// this is used for ObjectDestroy messages.
static bool SendToObservers<T>(NetworkIdentity identity, T msg) where T: IMessageBase
static bool SendToObservers<T>(NetworkIdentity identity, T msg) where T : IMessageBase
{
if (LogFilter.Debug) Debug.Log("Server.SendToObservers id:" + typeof(T));
@ -580,7 +580,7 @@ public static void RegisterHandler(MsgType msgType, NetworkMessageDelegate handl
/// <typeparam name="T">Message type</typeparam>
/// <param name="handler">Function handler which will be invoked for when this message type is received.</param>
/// <param name="requireAuthentication">True if the message requires an authenticated connection</param>
public static void RegisterHandler<T>(Action<NetworkConnection, T> handler, bool requireAuthentication = true) where T: IMessageBase, new()
public static void RegisterHandler<T>(Action<NetworkConnection, T> handler, bool requireAuthentication = true) where T : IMessageBase, new()
{
int msgType = MessagePacker.GetId<T>();
if (handlers.ContainsKey(msgType))
@ -692,7 +692,7 @@ public static void SendToClientOfPlayer(NetworkIdentity identity, int msgType, M
/// <typeparam name="T">Message type</typeparam>
/// <param name="identity"></param>
/// <param name="msg"></param>
public static void SendToClientOfPlayer<T>(NetworkIdentity identity, T msg) where T: IMessageBase
public static void SendToClientOfPlayer<T>(NetworkIdentity identity, T msg) where T : IMessageBase
{
if (identity != null)
{
@ -1061,7 +1061,7 @@ internal static void SendSpawnMessage(NetworkIdentity identity, NetworkConnectio
// convert to ArraySegment to avoid reader allocations
// (need to handle null case too)
ArraySegment<byte> ownerSegment = ownerWritten > 0 ? ownerWriter.ToArraySegment() : default;
ArraySegment<byte> ownerSegment = ownerWritten > 0 ? ownerWriter.ToArraySegment() : default;
ArraySegment<byte> observersSegment = observersWritten > 0 ? observersWriter.ToArraySegment() : default;
SpawnMessage msg = new SpawnMessage

View File

@ -288,19 +288,19 @@ public bool Remove(KeyValuePair<TKey, TValue> item)
IEnumerator IEnumerable.GetEnumerator() => objects.GetEnumerator();
}
public abstract class SyncDictionary<TKey, TValue>: SyncIDictionary<TKey, TValue>
public abstract class SyncDictionary<TKey, TValue> : SyncIDictionary<TKey, TValue>
{
protected SyncDictionary() : base(new Dictionary<TKey, TValue>())
{
}
protected SyncDictionary(IEqualityComparer<TKey> eq) : base(new Dictionary<TKey,TValue>(eq))
protected SyncDictionary(IEqualityComparer<TKey> eq) : base(new Dictionary<TKey, TValue>(eq))
{
}
public new Dictionary<TKey, TValue>.ValueCollection Values => ((Dictionary<TKey,TValue>)objects).Values;
public new Dictionary<TKey, TValue>.ValueCollection Values => ((Dictionary<TKey, TValue>)objects).Values;
public new Dictionary<TKey, TValue>.KeyCollection Keys => ((Dictionary<TKey,TValue>)objects).Keys;
public new Dictionary<TKey, TValue>.KeyCollection Keys => ((Dictionary<TKey, TValue>)objects).Keys;
public new Dictionary<TKey, TValue>.Enumerator GetEnumerator() => ((Dictionary<TKey, TValue>)objects).GetEnumerator();

View File

@ -384,7 +384,7 @@ public bool MoveNext()
public void Reset() => index = -1;
object IEnumerator.Current => Current;
public void Dispose() {}
public void Dispose() { }
}
}
}

View File

@ -341,8 +341,8 @@ public override void ServerStop()
public void LateUpdate()
{
// process all messages
while (ProcessClientMessage()) {}
while (ProcessServerMessage()) {}
while (ProcessClientMessage()) { }
while (ProcessServerMessage()) { }
}
public override void Shutdown()

View File

@ -46,9 +46,9 @@ void InitClient()
// wire all the base transports to my events
foreach (Transport transport in transports)
{
transport.OnClientConnected.AddListener(OnClientConnected.Invoke );
transport.OnClientConnected.AddListener(OnClientConnected.Invoke);
transport.OnClientDataReceived.AddListener(OnClientDataReceived.Invoke);
transport.OnClientError.AddListener(OnClientError.Invoke );
transport.OnClientError.AddListener(OnClientError.Invoke);
transport.OnClientDisconnected.AddListener(OnClientDisconnected.Invoke);
}
}

View File

@ -21,7 +21,7 @@ public int Count
{
get
{
lock(queue)
lock (queue)
{
return queue.Count;
}
@ -30,7 +30,7 @@ public int Count
public void Enqueue(T item)
{
lock(queue)
lock (queue)
{
queue.Enqueue(item);
}
@ -40,7 +40,7 @@ public void Enqueue(T item)
// so we need a TryDequeue
public bool TryDequeue(out T result)
{
lock(queue)
lock (queue)
{
result = default(T);
if (queue.Count > 0)
@ -56,7 +56,7 @@ public bool TryDequeue(out T result)
// locking every single TryDequeue.
public bool TryDequeueAll(out T[] result)
{
lock(queue)
lock (queue)
{
result = queue.ToArray();
queue.Clear();
@ -66,7 +66,7 @@ public bool TryDequeueAll(out T[] result)
public void Clear()
{
lock(queue)
lock (queue)
{
queue.Clear();
}

View File

@ -224,7 +224,7 @@ public void Stop()
TcpClient client = kvp.Value.client;
// close the stream if not closed yet. it may have been closed
// by a disconnect already, so use try/catch
try { client.GetStream().Close(); } catch {}
try { client.GetStream().Close(); } catch { }
client.Close();
}

View File

@ -115,8 +115,8 @@ public void LateUpdate()
// note: we need to check enabled in case we set it to false
// when LateUpdate already started.
// (https://github.com/vis2k/Mirror/pull/379)
while (enabled && ProcessClientMessage()) {}
while (enabled && ProcessServerMessage()) {}
while (enabled && ProcessClientMessage()) { }
while (enabled && ProcessServerMessage()) { }
}
// server

View File

@ -9,11 +9,11 @@
namespace Mirror
{
// UnityEvent definitions
[Serializable] public class ClientDataReceivedEvent : UnityEvent<ArraySegment<byte>, int> {}
[Serializable] public class UnityEventException : UnityEvent<Exception> {}
[Serializable] public class UnityEventInt : UnityEvent<int> {}
[Serializable] public class ServerDataReceivedEvent : UnityEvent<int, ArraySegment<byte>, int> {}
[Serializable] public class UnityEventIntException : UnityEvent<int, Exception> {}
[Serializable] public class ClientDataReceivedEvent : UnityEvent<ArraySegment<byte>, int> { }
[Serializable] public class UnityEventException : UnityEvent<Exception> { }
[Serializable] public class UnityEventInt : UnityEvent<int> { }
[Serializable] public class ServerDataReceivedEvent : UnityEvent<int, ArraySegment<byte>, int> { }
[Serializable] public class UnityEventIntException : UnityEvent<int, Exception> { }
public abstract class Transport : MonoBehaviour
{
@ -203,6 +203,6 @@ public virtual bool GetConnectionInfo(int connectionId, out string address)
// e.g. in uSurvival Transport would apply Cmds before
// ShoulderRotation.LateUpdate, resulting in projectile
// spawns at the point before shoulder rotation.
public void Update() {}
public void Update() { }
}
}

View File

@ -140,7 +140,7 @@ public void Disconnect()
if (webSocket != null)
{
// close client
webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure,"", CancellationToken.None);
webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "", CancellationToken.None);
webSocket = null;
Connecting = false;
IsConnected = false;
@ -169,7 +169,7 @@ public async void Send(ArraySegment<byte> segment)
public override string ToString()
{
if (IsConnected )
if (IsConnected)
{
return $"Websocket connected to {uri}";
}

View File

@ -65,7 +65,7 @@ public void Send(ArraySegment<byte> segment)
SocketSend(nativeRef, segment.Array, segment.Count);
}
#region Javascript native functions
#region Javascript native functions
[DllImport("__Internal")]
static extern int SocketCreate(
string url,
@ -83,9 +83,9 @@ static extern int SocketCreate(
[DllImport("__Internal")]
static extern void SocketClose(int socketInstance);
#endregion
#endregion
#region Javascript callbacks
#region Javascript callbacks
[MonoPInvokeCallback(typeof(Action))]
public static void OnOpen(int id)
@ -110,7 +110,7 @@ public static void OnData(int id, IntPtr ptr, int length)
clients[id].ReceivedData(new ArraySegment<byte>(data));
}
#endregion
#endregion
}
}

View File

@ -181,7 +181,8 @@ public override int ReadByte()
return _ms.ReadByte();
}
public override int ReadTimeout {
public override int ReadTimeout
{
get { return _ms.ReadTimeout; }
set { _ms.ReadTimeout = value; }
}

View File

@ -76,7 +76,7 @@ public static string ComputeSocketAcceptString(string secWebSocketKey)
/// <returns>The HTTP header</returns>
public static async Task<string> ReadHttpHeaderAsync(Stream stream, CancellationToken token)
{
int length = 1024*16; // 16KB buffer more than enough for http header
int length = 1024 * 16; // 16KB buffer more than enough for http header
byte[] buffer = new byte[length];
int offset = 0;
int bytesRead = 0;

View File

@ -116,7 +116,7 @@ public static void WriteInt(int value, Stream stream, bool isLittleEndian)
public static void WriteULong(ulong value, Stream stream, bool isLittleEndian)
{
byte[] buffer = BitConverter.GetBytes(value);
if (BitConverter.IsLittleEndian && ! isLittleEndian)
if (BitConverter.IsLittleEndian && !isLittleEndian)
{
Array.Reverse(buffer);
}

View File

@ -55,7 +55,7 @@ public static async Task<WebSocketFrame> ReadAsync(Stream fromStream, ArraySegme
byte finBitFlag = 0x80;
byte opCodeFlag = 0x0F;
bool isFinBitSet = (byte1 & finBitFlag) == finBitFlag;
WebSocketOpCode opCode = (WebSocketOpCode) (byte1 & opCodeFlag);
WebSocketOpCode opCode = (WebSocketOpCode)(byte1 & opCodeFlag);
// read and process second byte
byte maskFlag = 0x80;
@ -143,7 +143,7 @@ static WebSocketFrame DecodeCloseFrame(bool isFinBitSet, WebSocketOpCode opCode,
static async Task<uint> ReadLength(byte byte2, ArraySegment<byte> smallBuffer, Stream fromStream, CancellationToken cancellationToken)
{
byte payloadLenFlag = 0x7F;
uint len = (uint) (byte2 & payloadLenFlag);
uint len = (uint)(byte2 & payloadLenFlag);
// read a short length or a long length depending on the value of len
if (len == 126)
@ -152,7 +152,7 @@ static async Task<uint> ReadLength(byte byte2, ArraySegment<byte> smallBuffer, S
}
else if (len == 127)
{
len = (uint) await BinaryReaderWriter.ReadULongExactly(fromStream, false, smallBuffer, cancellationToken);
len = (uint)await BinaryReaderWriter.ReadULongExactly(fromStream, false, smallBuffer, cancellationToken);
const uint maxLen = 2147483648; // 2GB - not part of the spec but just a precaution. Send large volumes of data in smaller frames.
// protect ourselves against bad data

View File

@ -528,7 +528,7 @@ ArraySegment<byte> GetBuffer(MemoryStream stream)
async Task WriteStreamToNetwork(MemoryStream stream, CancellationToken cancellationToken)
{
ArraySegment<byte> buffer = GetBuffer(stream);
if(_stream is SslStream)
if (_stream is SslStream)
{
_messageQueue.Enqueue(buffer);
await _sendSemaphore.WaitAsync();

View File

@ -29,7 +29,7 @@ public class WebSocketClientOptions
/// <summary>
/// Add any additional http headers to this dictionary
/// </summary>
public Dictionary<string,string> AdditionalHttpHeaders { get; set; }
public Dictionary<string, string> AdditionalHttpHeaders { get; set; }
/// <summary>
/// Include the full exception (with stack trace) in the close response

View File

@ -143,7 +143,7 @@ async Task ProcessTcpClient(TcpClient tcpClient, CancellationToken token)
}
}
catch(IOException)
catch (IOException)
{
// do nothing. This will be thrown if the transport is closed
}
@ -277,7 +277,8 @@ public async void Send(int connectionId, ArraySegment<byte> segment)
{
await client.SendAsync(segment, WebSocketMessageType.Binary, true, cancellation.Token);
}
catch (ObjectDisposedException) {
catch (ObjectDisposedException)
{
// connection has been closed, swallow exception
Disconnect(connectionId);
}

View File

@ -32,12 +32,12 @@ public void TestEmptyByteArray()
Assert.That(unpacked.array.Count, Is.EqualTo(0));
}
public static ArraySegment<int> SampleReader(NetworkReader reader )
public static ArraySegment<int> SampleReader(NetworkReader reader)
{
int length = reader.ReadPackedInt32();
int[] array = new int[length];
for (int i=0; i< length; i++)
for (int i = 0; i < length; i++)
{
array[i] = reader.ReadPackedInt32();
}

View File

@ -83,14 +83,14 @@ public void TestEmptyIntArray()
{
ArrayIntMessage intMessage = new ArrayIntMessage
{
array = new int [] { }
array = new int[] { }
};
byte[] data = MessagePacker.Pack(intMessage);
ArrayIntMessage unpacked = MessagePacker.Unpack<ArrayIntMessage>(data);
Assert.That(unpacked.array, Is.EquivalentTo(new int[] {}));
Assert.That(unpacked.array, Is.EquivalentTo(new int[] { }));
}
[Test]
@ -98,14 +98,14 @@ public void TestDataIntArray()
{
ArrayIntMessage intMessage = new ArrayIntMessage
{
array = new[] { 3, 4, 5}
array = new[] { 3, 4, 5 }
};
byte[] data = MessagePacker.Pack(intMessage);
ArrayIntMessage unpacked = MessagePacker.Unpack<ArrayIntMessage>(data);
Assert.That(unpacked.array, Is.EquivalentTo(new int[] {3, 4, 5 }));
Assert.That(unpacked.array, Is.EquivalentTo(new int[] { 3, 4, 5 }));
}
}
}

View File

@ -9,16 +9,16 @@ public class FloatBytePackerTest
[Test]
public void TestScaleFloatToByte()
{
Assert.That(FloatBytePacker.ScaleFloatToByte( -1f, -1f, 1f, byte.MinValue, byte.MaxValue), Is.EqualTo(0));
Assert.That(FloatBytePacker.ScaleFloatToByte( 0f, -1f, 1f, byte.MinValue, byte.MaxValue), Is.EqualTo(127));
Assert.That(FloatBytePacker.ScaleFloatToByte(-1f, -1f, 1f, byte.MinValue, byte.MaxValue), Is.EqualTo(0));
Assert.That(FloatBytePacker.ScaleFloatToByte(0f, -1f, 1f, byte.MinValue, byte.MaxValue), Is.EqualTo(127));
Assert.That(FloatBytePacker.ScaleFloatToByte(0.5f, -1f, 1f, byte.MinValue, byte.MaxValue), Is.EqualTo(191));
Assert.That(FloatBytePacker.ScaleFloatToByte( 1f, -1f, 1f, byte.MinValue, byte.MaxValue), Is.EqualTo(255));
Assert.That(FloatBytePacker.ScaleFloatToByte(1f, -1f, 1f, byte.MinValue, byte.MaxValue), Is.EqualTo(255));
}
[Test]
public void ScaleByteToFloat()
{
Assert.That(FloatBytePacker.ScaleByteToFloat( 0, byte.MinValue, byte.MaxValue, -1, 1), Is.EqualTo(-1).Within(0.0001f));
Assert.That(FloatBytePacker.ScaleByteToFloat(0, byte.MinValue, byte.MaxValue, -1, 1), Is.EqualTo(-1).Within(0.0001f));
Assert.That(FloatBytePacker.ScaleByteToFloat(127, byte.MinValue, byte.MaxValue, -1, 1), Is.EqualTo(-0.003921569f).Within(0.0001f));
Assert.That(FloatBytePacker.ScaleByteToFloat(191, byte.MinValue, byte.MaxValue, -1, 1), Is.EqualTo(0.4980392f).Within(0.0001f));
Assert.That(FloatBytePacker.ScaleByteToFloat(255, byte.MinValue, byte.MaxValue, -1, 1), Is.EqualTo(1).Within(0.0001f));

View File

@ -30,14 +30,14 @@ public void Serialize(NetworkWriter writer)
}
}
struct WovenTestMessage: IMessageBase
struct WovenTestMessage : IMessageBase
{
public int IntValue;
public string StringValue;
public double DoubleValue;
public void Deserialize(NetworkReader reader) {}
public void Serialize(NetworkWriter writer) {}
public void Deserialize(NetworkReader reader) { }
public void Serialize(NetworkWriter writer) { }
}
[TestFixture]
@ -62,7 +62,7 @@ public void Roundtrip()
public void WovenSerializationBodyRoundtrip()
{
NetworkWriter w = new NetworkWriter();
w.Write(new WovenTestMessage{IntValue = 1, StringValue = "2", DoubleValue = 3.3});
w.Write(new WovenTestMessage { IntValue = 1, StringValue = "2", DoubleValue = 3.3 });
byte[] arr = w.ToArray();

View File

@ -26,7 +26,7 @@ public void SetupMultipex()
GameObject gameObject = new GameObject();
transport = gameObject.AddComponent<MultiplexTransport>();
transport.transports = new []{ transport1, transport2 };
transport.transports = new[] { transport1, transport2 };
transport.Awake();
}

View File

@ -43,7 +43,7 @@ public void TestWritingHugeArray()
[Test]
public void TestWritingBytesSegment()
{
byte[] data = {1, 2, 3};
byte[] data = { 1, 2, 3 };
NetworkWriter writer = new NetworkWriter();
writer.WriteBytes(data, 0, data.Length);
@ -58,7 +58,7 @@ public void TestWritingBytesSegment()
[Test]
public void TestWritingBytesAndReadingSegment()
{
byte[] data = {1, 2, 3};
byte[] data = { 1, 2, 3 };
NetworkWriter writer = new NetworkWriter();
writer.WriteBytesAndSize(data);
@ -73,7 +73,7 @@ public void TestWritingBytesAndReadingSegment()
[Test]
public void TestWritingSegmentAndReadingSegment()
{
byte[] data = {1, 2, 3, 4};
byte[] data = { 1, 2, 3, 4 };
ArraySegment<byte> segment = new ArraySegment<byte>(data, 1, 1); // [2, 3]
NetworkWriter writer = new NetworkWriter();
writer.WriteBytesAndSizeSegment(segment);
@ -169,7 +169,7 @@ public void TestReadingLengthWrapAround()
public void TestReading0LengthBytesAndSize()
{
NetworkWriter writer = new NetworkWriter();
writer.WriteBytesAndSize(new byte[]{});
writer.WriteBytesAndSize(new byte[] { });
NetworkReader reader = new NetworkReader(writer.ToArray());
Assert.That(reader.ReadBytesAndSize().Length, Is.EqualTo(0));
}
@ -178,7 +178,7 @@ public void TestReading0LengthBytesAndSize()
public void TestReading0LengthBytes()
{
NetworkWriter writer = new NetworkWriter();
writer.WriteBytes(new byte[]{}, 0, 0);
writer.WriteBytes(new byte[] { }, 0, 0);
NetworkReader reader = new NetworkReader(writer.ToArray());
Assert.That(reader.ReadBytes(0).Length, Is.EqualTo(0));
}
@ -196,7 +196,7 @@ public void TestReadingTooMuch()
{
void EnsureThrows(Action<NetworkReader> read, byte[] data = null)
{
Assert.Throws<System.IO.EndOfStreamException>(() => read(new NetworkReader(data ?? new byte[]{})));
Assert.Throws<System.IO.EndOfStreamException>(() => read(new NetworkReader(data ?? new byte[] { })));
}
// Try reading more than there is data to be read from
// This should throw EndOfStreamException always
@ -655,19 +655,22 @@ public void TestPackedUInt32()
[Test]
public void TestPackedUInt32Failure()
{
Assert.Throws<System.OverflowException>(() => {
Assert.Throws<System.OverflowException>(() =>
{
NetworkWriter writer = new NetworkWriter();
writer.WritePackedUInt64(1099511627775);
NetworkReader reader = new NetworkReader(writer.ToArray());
reader.ReadPackedUInt32();
});
Assert.Throws<System.OverflowException>(() => {
Assert.Throws<System.OverflowException>(() =>
{
NetworkWriter writer = new NetworkWriter();
writer.WritePackedUInt64(281474976710655);
NetworkReader reader = new NetworkReader(writer.ToArray());
reader.ReadPackedUInt32();
});
Assert.Throws<System.OverflowException>(() => {
Assert.Throws<System.OverflowException>(() =>
{
NetworkWriter writer = new NetworkWriter();
writer.WritePackedUInt64(72057594037927935);
NetworkReader reader = new NetworkReader(writer.ToArray());
@ -714,19 +717,22 @@ public void TestPackedInt32()
[Test]
public void TestPackedInt32Failure()
{
Assert.Throws<System.OverflowException>(() => {
Assert.Throws<System.OverflowException>(() =>
{
NetworkWriter writer = new NetworkWriter();
writer.WritePackedInt64(1099511627775);
NetworkReader reader = new NetworkReader(writer.ToArray());
reader.ReadPackedInt32();
});
Assert.Throws<System.OverflowException>(() => {
Assert.Throws<System.OverflowException>(() =>
{
NetworkWriter writer = new NetworkWriter();
writer.WritePackedInt64(281474976710655);
NetworkReader reader = new NetworkReader(writer.ToArray());
reader.ReadPackedInt32();
});
Assert.Throws<System.OverflowException>(() => {
Assert.Throws<System.OverflowException>(() =>
{
NetworkWriter writer = new NetworkWriter();
writer.WritePackedInt64(72057594037927935);
NetworkReader reader = new NetworkReader(writer.ToArray());
@ -974,8 +980,8 @@ public void TestDecimalBinaryCompatibility()
[Test]
public void TestByteEndianness()
{
byte[] values = {0x12,0x43,0x00,0xff,0xab,0x02,0x20};
byte[] expected = {0x12,0x43,0x00,0xff,0xab,0x02,0x20};
byte[] values = { 0x12, 0x43, 0x00, 0xff, 0xab, 0x02, 0x20 };
byte[] expected = { 0x12, 0x43, 0x00, 0xff, 0xab, 0x02, 0x20 };
NetworkWriter writer = new NetworkWriter();
foreach (byte value in values)
{
@ -987,8 +993,8 @@ public void TestByteEndianness()
[Test]
public void TestUShortEndianness()
{
ushort[] values = {0x0000,0x1234,0xabcd,0xF00F,0x0FF0,0xbeef};
byte[] expected = {0x00,0x00,0x34,0x12,0xcd,0xab,0x0F,0xF0,0xF0,0x0F,0xef,0xbe};
ushort[] values = { 0x0000, 0x1234, 0xabcd, 0xF00F, 0x0FF0, 0xbeef };
byte[] expected = { 0x00, 0x00, 0x34, 0x12, 0xcd, 0xab, 0x0F, 0xF0, 0xF0, 0x0F, 0xef, 0xbe };
NetworkWriter writer = new NetworkWriter();
foreach (ushort value in values)
{
@ -1000,8 +1006,8 @@ public void TestUShortEndianness()
[Test]
public void TestUIntEndianness()
{
uint[] values = {0x12345678,0xabcdef09,0xdeadbeef};
byte[] expected = {0x78,0x56,0x34,0x12,0x09,0xef,0xcd,0xab,0xef,0xbe,0xad,0xde};
uint[] values = { 0x12345678, 0xabcdef09, 0xdeadbeef };
byte[] expected = { 0x78, 0x56, 0x34, 0x12, 0x09, 0xef, 0xcd, 0xab, 0xef, 0xbe, 0xad, 0xde };
NetworkWriter writer = new NetworkWriter();
foreach (uint value in values)
{
@ -1013,8 +1019,8 @@ public void TestUIntEndianness()
[Test]
public void TestULongEndianness()
{
ulong[] values = {0x0123456789abcdef,0xdeaded_beef_c0ffee};
byte[] expected = {0xef,0xcd,0xab,0x89,0x67,0x45,0x23,0x01,0xee,0xff,0xc0,0xef,0xbe,0xed,0xad,0xde};
ulong[] values = { 0x0123456789abcdef, 0xdeaded_beef_c0ffee };
byte[] expected = { 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0xee, 0xff, 0xc0, 0xef, 0xbe, 0xed, 0xad, 0xde };
NetworkWriter writer = new NetworkWriter();
foreach (ulong value in values)
{
@ -1026,12 +1032,12 @@ public void TestULongEndianness()
[Test]
public void TestSbyteEndianness()
{
byte[] values = {0x12,0x43,0x00,0xff,0xab,0x02,0x20};
byte[] expected = {0x12,0x43,0x00,0xff,0xab,0x02,0x20};
byte[] values = { 0x12, 0x43, 0x00, 0xff, 0xab, 0x02, 0x20 };
byte[] expected = { 0x12, 0x43, 0x00, 0xff, 0xab, 0x02, 0x20 };
NetworkWriter writer = new NetworkWriter();
foreach (byte value in values)
{
writer.WriteSByte((sbyte) value);
writer.WriteSByte((sbyte)value);
}
Assert.That(writer.ToArray(), Is.EqualTo(expected));
}
@ -1039,12 +1045,12 @@ public void TestSbyteEndianness()
[Test]
public void TestShortEndianness()
{
ushort[] values = {0x0000,0x1234,0xabcd,0xF00F,0x0FF0,0xbeef};
byte[] expected = {0x00,0x00,0x34,0x12,0xcd,0xab,0x0F,0xF0,0xF0,0x0F,0xef,0xbe};
ushort[] values = { 0x0000, 0x1234, 0xabcd, 0xF00F, 0x0FF0, 0xbeef };
byte[] expected = { 0x00, 0x00, 0x34, 0x12, 0xcd, 0xab, 0x0F, 0xF0, 0xF0, 0x0F, 0xef, 0xbe };
NetworkWriter writer = new NetworkWriter();
foreach (ushort value in values)
{
writer.WriteInt16((short) value);
writer.WriteInt16((short)value);
}
Assert.That(writer.ToArray(), Is.EqualTo(expected));
}
@ -1052,12 +1058,12 @@ public void TestShortEndianness()
[Test]
public void TestIntEndianness()
{
uint[] values = {0x12345678,0xabcdef09,0xdeadbeef};
byte[] expected = {0x78,0x56,0x34,0x12,0x09,0xef,0xcd,0xab,0xef,0xbe,0xad,0xde};
uint[] values = { 0x12345678, 0xabcdef09, 0xdeadbeef };
byte[] expected = { 0x78, 0x56, 0x34, 0x12, 0x09, 0xef, 0xcd, 0xab, 0xef, 0xbe, 0xad, 0xde };
NetworkWriter writer = new NetworkWriter();
foreach (uint value in values)
{
writer.WriteInt32((int) value);
writer.WriteInt32((int)value);
}
Assert.That(writer.ToArray(), Is.EqualTo(expected));
}
@ -1065,12 +1071,12 @@ public void TestIntEndianness()
[Test]
public void TestLongEndianness()
{
ulong[] values = {0x0123456789abcdef,0xdeaded_beef_c0ffee};
byte[] expected = {0xef,0xcd,0xab,0x89,0x67,0x45,0x23,0x01,0xee,0xff,0xc0,0xef,0xbe,0xed,0xad,0xde};
ulong[] values = { 0x0123456789abcdef, 0xdeaded_beef_c0ffee };
byte[] expected = { 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0xee, 0xff, 0xc0, 0xef, 0xbe, 0xed, 0xad, 0xde };
NetworkWriter writer = new NetworkWriter();
foreach (ulong value in values)
{
writer.WriteInt64((long) value);
writer.WriteInt64((long)value);
}
Assert.That(writer.ToArray(), Is.EqualTo(expected));
}

View File

@ -7,7 +7,7 @@ namespace Mirror.Tests
[TestFixture]
public class SyncDictionaryTest
{
public class SyncDictionaryIntString : SyncDictionary<int, string> {}
public class SyncDictionaryIntString : SyncDictionary<int, string> { }
SyncDictionaryIntString serverSyncDictionary;
SyncDictionaryIntString clientSyncDictionary;
@ -189,11 +189,11 @@ public void CountTest()
[Test]
public void CopyToTest()
{
KeyValuePair<int, string> [] data = new KeyValuePair<int, string>[3];
KeyValuePair<int, string>[] data = new KeyValuePair<int, string>[3];
clientSyncDictionary.CopyTo(data, 0);
Assert.That(data, Is.EquivalentTo(new KeyValuePair<int,string>[]
Assert.That(data, Is.EquivalentTo(new KeyValuePair<int, string>[]
{
new KeyValuePair<int, string>(0, "Hello"),
new KeyValuePair<int, string>(1, "World"),

View File

@ -9,7 +9,7 @@ public class SyncListTest
SyncListString serverSyncList;
SyncListString clientSyncList;
void SerializeAllTo<T>(T fromList, T toList) where T: SyncObject
void SerializeAllTo<T>(T fromList, T toList) where T : SyncObject
{
NetworkWriter writer = new NetworkWriter();
fromList.OnSerializeAll(writer);
@ -42,7 +42,7 @@ public void SetUp()
[Test]
public void TestInit()
{
Assert.That(clientSyncList, Is.EquivalentTo(new []{"Hello", "World", "!"}));
Assert.That(clientSyncList, Is.EquivalentTo(new[] { "Hello", "World", "!" }));
}
[Test]
@ -58,15 +58,15 @@ public void TestClear()
{
serverSyncList.Clear();
SerializeDeltaTo(serverSyncList, clientSyncList);
Assert.That(clientSyncList, Is.EquivalentTo(new string[] {}));
Assert.That(clientSyncList, Is.EquivalentTo(new string[] { }));
}
[Test]
public void TestInsert()
{
serverSyncList.Insert(0,"yay");
serverSyncList.Insert(0, "yay");
SerializeDeltaTo(serverSyncList, clientSyncList);
Assert.That(clientSyncList, Is.EquivalentTo(new[] {"yay", "Hello", "World", "!" }));
Assert.That(clientSyncList, Is.EquivalentTo(new[] { "yay", "Hello", "World", "!" }));
}
[Test]
@ -121,7 +121,7 @@ public void TestMultSync()
// add some delta and see if it applies
serverSyncList.Add("2");
SerializeDeltaTo(serverSyncList, clientSyncList);
Assert.That(clientSyncList, Is.EquivalentTo(new[] { "Hello", "World", "!", "1","2" }));
Assert.That(clientSyncList, Is.EquivalentTo(new[] { "Hello", "World", "!", "1", "2" }));
}
[Test]
@ -135,7 +135,7 @@ public void SyncListIntTest()
serverList.Add(3);
SerializeDeltaTo(serverList, clientList);
Assert.That(clientList, Is.EquivalentTo(new [] {1,2,3}));
Assert.That(clientList, Is.EquivalentTo(new[] { 1, 2, 3 }));
}
[Test]

View File

@ -7,7 +7,7 @@ namespace Mirror.Tests
[TestFixture]
public class SyncSetTest
{
public class SyncSetString : SyncHashSet<string> {}
public class SyncSetString : SyncHashSet<string> { }
SyncSetString serverSyncSet;
SyncSetString clientSyncSet;
@ -45,8 +45,8 @@ public void SetUp()
[Test]
public void TestInit()
{
Assert.That(serverSyncSet, Is.EquivalentTo(new[] {"Hello", "World", "!"}));
Assert.That(clientSyncSet, Is.EquivalentTo(new[] {"Hello", "World", "!"}));
Assert.That(serverSyncSet, Is.EquivalentTo(new[] { "Hello", "World", "!" }));
Assert.That(clientSyncSet, Is.EquivalentTo(new[] { "Hello", "World", "!" }));
}
[Test]
@ -65,7 +65,7 @@ public void TestClear()
serverSyncSet.Clear();
Assert.That(serverSyncSet.IsDirty, Is.True);
SerializeDeltaTo(serverSyncSet, clientSyncSet);
Assert.That(clientSyncSet, Is.EquivalentTo(new string[] {}));
Assert.That(clientSyncSet, Is.EquivalentTo(new string[] { }));
Assert.That(serverSyncSet.IsDirty, Is.False);
}
@ -87,7 +87,7 @@ public void TestMultSync()
// add some delta and see if it applies
serverSyncSet.Add("2");
SerializeDeltaTo(serverSyncSet, clientSyncSet);
Assert.That(clientSyncSet, Is.EquivalentTo(new[] { "Hello", "World", "!", "1","2" }));
Assert.That(clientSyncSet, Is.EquivalentTo(new[] { "Hello", "World", "!", "1", "2" }));
}
[Test]
@ -164,7 +164,7 @@ public void TestExceptWith()
{
serverSyncSet.ExceptWith(new[] { "World", "Hello" });
SerializeDeltaTo(serverSyncSet, clientSyncSet);
Assert.That(clientSyncSet, Is.EquivalentTo(new[] { "!" }));
Assert.That(clientSyncSet, Is.EquivalentTo(new[] { "!" }));
}
[Test]
@ -172,7 +172,7 @@ public void TestExceptWithSelf()
{
serverSyncSet.ExceptWith(serverSyncSet);
SerializeDeltaTo(serverSyncSet, clientSyncSet);
Assert.That(clientSyncSet, Is.EquivalentTo(new String [] {}));
Assert.That(clientSyncSet, Is.EquivalentTo(new String[] { }));
}
[Test]
@ -206,7 +206,7 @@ public void TestIsProperSubsetOfSet()
[Test]
public void TestIsNotProperSubsetOf()
{
Assert.That(clientSyncSet.IsProperSubsetOf(new[] { "World", "!", "pepe"}), Is.False);
Assert.That(clientSyncSet.IsProperSubsetOf(new[] { "World", "!", "pepe" }), Is.False);
}
[Test]
@ -230,13 +230,13 @@ public void TestIsSupersetOf()
[Test]
public void TestOverlaps()
{
Assert.That(clientSyncSet.Overlaps(new[] { "World", "my", "baby"}));
Assert.That(clientSyncSet.Overlaps(new[] { "World", "my", "baby" }));
}
[Test]
public void TestSetEquals()
{
Assert.That(clientSyncSet.SetEquals(new[] { "World","Hello", "!" }));
Assert.That(clientSyncSet.SetEquals(new[] { "World", "Hello", "!" }));
}
[Test]

View File

@ -151,8 +151,8 @@ static void BuildAssembly(bool wait)
assemblyBuilder.buildStarted += delegate (string assemblyPath)
{
//Debug.LogFormat("Assembly build started for {0}", assemblyPath);
};
//Debug.LogFormat("Assembly build started for {0}", assemblyPath);
};
assemblyBuilder.buildFinished += delegate (string assemblyPath, CompilerMessage[] compilerMessages)
{
@ -161,8 +161,8 @@ static void BuildAssembly(bool wait)
{
if (cm.type == CompilerMessageType.Warning)
{
//Debug.LogWarningFormat("{0}:{1} -- {2}", cm.file, cm.line, cm.message);
}
//Debug.LogWarningFormat("{0}:{1} -- {2}", cm.file, cm.line, cm.message);
}
else if (cm.type == CompilerMessageType.Error)
{
Debug.LogErrorFormat("{0}:{1} -- {2}", cm.file, cm.line, cm.message);

View File

@ -160,7 +160,7 @@ public void SyncVarsWrongHookType()
Assert.That(weaverErrors, Contains.Item("Mirror.Weaver error: System.Void MirrorTest.MirrorTestPlayer::OnChangeHealth(System.Boolean) should have signature:\npublic void OnChangeHealth(System.Int32 value) { }"));
}
[Test]
[Test]
public void SyncVarsDerivedNetworkBehaviour()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.True);
@ -242,7 +242,8 @@ public void SyncListMissingParamlessCtor()
}
[Test]
public void SyncListByteValid() {
public void SyncListByteValid()
{
Assert.That(CompilationFinishedHook.WeaveFailed, Is.False);
Assert.That(weaverErrors, Is.Empty);
}