You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-16 07:06:30 +09:00
Changed target framework to 4.5.1 for all projects
Changed some minor things after running .net portability analyzer Fixed a bunch of warnings (mostly CLS compliance)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@@ -10,7 +10,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Lidgren.Network</RootNamespace>
|
||||
<AssemblyName>Lidgren.Network</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
@@ -27,6 +27,7 @@
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -38,6 +39,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<DocumentationFile>bin\Debug\Lidgren.Network.XML</DocumentationFile>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -47,6 +49,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Lidgren.Network
|
||||
value = readMethod.Invoke(this, null);
|
||||
|
||||
// set the value
|
||||
var setMethod = fi.GetSetMethod((flags & BindingFlags.NonPublic) == BindingFlags.NonPublic);
|
||||
var setMethod = fi.SetMethod;
|
||||
if (setMethod != null)
|
||||
setMethod.Invoke(target, new object[] { value });
|
||||
}
|
||||
|
||||
@@ -78,13 +78,16 @@ namespace Lidgren.Network
|
||||
|
||||
foreach (PropertyInfo fi in fields)
|
||||
{
|
||||
MethodInfo getMethod = fi.GetGetMethod((flags & BindingFlags.NonPublic) == BindingFlags.NonPublic);
|
||||
object value = getMethod.Invoke(ob, null);
|
||||
MethodInfo getMethod = fi.GetMethod;
|
||||
if (getMethod != null)
|
||||
{
|
||||
object value = getMethod.Invoke(ob, null);
|
||||
|
||||
// find the appropriate Write method
|
||||
MethodInfo writeMethod;
|
||||
if (s_writeMethods.TryGetValue(fi.PropertyType, out writeMethod))
|
||||
writeMethod.Invoke(this, new object[] { value });
|
||||
// find the appropriate Write method
|
||||
MethodInfo writeMethod;
|
||||
if (s_writeMethods.TryGetValue(fi.PropertyType, out writeMethod))
|
||||
writeMethod.Invoke(this, new object[] { value });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace Lidgren.Network
|
||||
/// <summary>
|
||||
/// Exception thrown in the Lidgren Network Library
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class NetException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
@@ -52,14 +51,6 @@ namespace Lidgren.Network
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NetException constructor
|
||||
/// </summary>
|
||||
private NetException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws an exception, in DEBUG only, if first parameter is false
|
||||
/// </summary>
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Lidgren.Network
|
||||
{
|
||||
if (string.IsNullOrEmpty(appIdentifier))
|
||||
throw new NetException("App identifier must be at least one character long");
|
||||
m_appIdentifier = appIdentifier.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||
m_appIdentifier = appIdentifier;
|
||||
|
||||
//
|
||||
// default values
|
||||
|
||||
@@ -17,18 +17,21 @@ namespace Lidgren.Network
|
||||
Initialize(NetRandomSeed.GetUInt64());
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public override void Initialize(uint seed)
|
||||
{
|
||||
m_w = seed;
|
||||
m_z = seed * 16777619;
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public void Initialize(ulong seed)
|
||||
{
|
||||
m_w = (uint)seed;
|
||||
m_z = (uint)(seed >> 32);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public override uint NextUInt32()
|
||||
{
|
||||
m_z = 36969 * (m_z & 65535) + (m_z >> 16);
|
||||
@@ -56,11 +59,13 @@ namespace Lidgren.Network
|
||||
Initialize(NetRandomSeed.GetUInt64());
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public XorShiftRandom(ulong seed)
|
||||
{
|
||||
Initialize(seed);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public override void Initialize(uint seed)
|
||||
{
|
||||
m_x = (uint)seed;
|
||||
@@ -69,6 +74,7 @@ namespace Lidgren.Network
|
||||
m_w = c_w;
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public void Initialize(ulong seed)
|
||||
{
|
||||
m_x = (uint)seed;
|
||||
@@ -77,6 +83,7 @@ namespace Lidgren.Network
|
||||
m_w = c_w;
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public override uint NextUInt32()
|
||||
{
|
||||
uint t = (m_x ^ (m_x << 11));
|
||||
@@ -115,11 +122,13 @@ namespace Lidgren.Network
|
||||
Initialize(NetRandomSeed.GetUInt32());
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public MersenneTwisterRandom(uint seed)
|
||||
{
|
||||
Initialize(seed);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public override void Initialize(uint seed)
|
||||
{
|
||||
mt = new UInt32[N];
|
||||
@@ -130,6 +139,7 @@ namespace Lidgren.Network
|
||||
mt[i] = (UInt32)(1812433253 * (mt[i - 1] ^ (mt[i - 1] >> 30)) + i);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public override uint NextUInt32()
|
||||
{
|
||||
UInt32 y;
|
||||
@@ -181,12 +191,14 @@ namespace Lidgren.Network
|
||||
/// <summary>
|
||||
/// Seed in CryptoRandom does not create deterministic sequences
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public override void Initialize(uint seed)
|
||||
{
|
||||
byte[] tmp = new byte[seed % 16];
|
||||
m_rnd.GetBytes(tmp); // just prime it
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public override uint NextUInt32()
|
||||
{
|
||||
var bytes = new byte[4];
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace Lidgren.Network
|
||||
/// </summary>
|
||||
public abstract class NetRandom : Random
|
||||
{
|
||||
public static NetRandom Instance = new MWCRandom();
|
||||
|
||||
private const double c_realUnitInt = 1.0 / ((double)int.MaxValue + 1.0);
|
||||
|
||||
public NetRandom()
|
||||
@@ -21,12 +23,22 @@ namespace Lidgren.Network
|
||||
Initialize((uint)seed);
|
||||
}
|
||||
|
||||
public abstract void Initialize(uint seed);
|
||||
[CLSCompliant(false)]
|
||||
public virtual void Initialize(uint seed)
|
||||
{
|
||||
// should be abstract, but non-CLS compliant methods can't be abstract!
|
||||
throw new NotImplementedException("Implement this in inherited classes");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a random value from UInt32.MinValue to UInt32.MaxValue, inclusively
|
||||
/// </summary>
|
||||
public abstract uint NextUInt32();
|
||||
[CLSCompliant(false)]
|
||||
public virtual uint NextUInt32()
|
||||
{
|
||||
// should be abstract, but non-CLS compliant methods can't be abstract!
|
||||
throw new NotImplementedException("Implement this in inherited classes");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a random value that is >= 0 and < Int32.MaxValue
|
||||
@@ -93,6 +105,7 @@ namespace Lidgren.Network
|
||||
/// <summary>
|
||||
/// Generates a random value between UInt64.MinValue to UInt64.MaxValue
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public ulong NextUInt64()
|
||||
{
|
||||
ulong retval = NextUInt32();
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Lidgren.Network
|
||||
/// <summary>
|
||||
/// Generates a 32 bit random seed
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public static uint GetUInt32()
|
||||
{
|
||||
ulong seed = GetUInt64();
|
||||
@@ -21,6 +22,7 @@ namespace Lidgren.Network
|
||||
/// <summary>
|
||||
/// Generates a 64 bit random seed
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public static ulong GetUInt64()
|
||||
{
|
||||
#if !__ANDROID__ && !IOS && !UNITY_WEBPLAYER
|
||||
|
||||
Reference in New Issue
Block a user