Created
April 19, 2013 04:19
-
-
Save matthargett/5418124 to your computer and use it in GitHub Desktop.
patch that fixes compilation of MonoGame.PSM project, along with some cleanups suggested by ReSharper.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/MonoGame.Framework/Content/ContentManager.cs b/MonoGame.Framework/Content/ContentManager.cs | |
old mode 100644 | |
new mode 100755 | |
diff --git a/MonoGame.Framework/Content/ContentTypeReaderManager.cs b/MonoGame.Framework/Content/ContentTypeReaderManager.cs | |
old mode 100644 | |
new mode 100755 | |
index 484abce..fe41140 | |
--- a/MonoGame.Framework/Content/ContentTypeReaderManager.cs | |
+++ b/MonoGame.Framework/Content/ContentTypeReaderManager.cs | |
@@ -156,7 +156,7 @@ namespace Microsoft.Xna.Framework.Content | |
// In particular, MonoTouch needs help instantiating types that are only defined in strings in Xnb files. | |
throw new InvalidOperationException( | |
"Failed to get default constructor for ContentTypeReader. To work around, add a creation function to ContentTypeReaderManager.AddTypeCreator() " + | |
- "with the following failed type string: " + originalReaderTypeString); | |
+ "with the following failed type string: " + originalReaderTypeString, ex); | |
} | |
} | |
else | |
diff --git a/MonoGame.Framework/GamerServices/GamerProfile.cs b/MonoGame.Framework/GamerServices/GamerProfile.cs | |
old mode 100644 | |
new mode 100755 | |
index 2bf7569..b69d744 | |
--- a/MonoGame.Framework/GamerServices/GamerProfile.cs | |
+++ b/MonoGame.Framework/GamerServices/GamerProfile.cs | |
@@ -64,7 +64,7 @@ namespace Microsoft.Xna.Framework.GamerServices | |
GC.SuppressFinalize(this); | |
} | |
- protected void Dispose(bool disposing) | |
+ public void Dispose(bool disposing) | |
{ | |
} | |
diff --git a/MonoGame.Framework/Graphics/Effect/Effect.cs b/MonoGame.Framework/Graphics/Effect/Effect.cs | |
old mode 100644 | |
new mode 100755 | |
index 5dbe397..2d9cf77 | |
--- a/MonoGame.Framework/Graphics/Effect/Effect.cs | |
+++ b/MonoGame.Framework/Graphics/Effect/Effect.cs | |
@@ -40,12 +40,9 @@ | |
// | |
using System; | |
using System.Collections.Generic; | |
-using System.Diagnostics; | |
-using System.Text; | |
-using System.IO; | |
-using System.Linq; | |
-using System.Reflection; | |
- | |
+using System.Diagnostics; | |
+using System.IO; | |
+ | |
#if PSM | |
using Sce.PlayStation.Core.Graphics; | |
#endif | |
@@ -69,9 +66,9 @@ namespace Microsoft.Xna.Framework.Graphics | |
internal Effect(GraphicsDevice graphicsDevice) | |
{ | |
if (graphicsDevice == null) | |
- throw new ArgumentNullException ("Graphics Device Cannot Be Null"); | |
+ throw new ArgumentNullException ("graphicsDevice"); | |
- this.GraphicsDevice = graphicsDevice; | |
+ GraphicsDevice = graphicsDevice; | |
} | |
protected Effect(Effect cloneSource) | |
@@ -208,13 +205,13 @@ namespace Microsoft.Xna.Framework.Graphics | |
base.Dispose(disposing); | |
} | |
- internal protected override void GraphicsDeviceResetting() | |
- { | |
- for (var i = 0; i < ConstantBuffers.Length; i++) | |
- ConstantBuffers[i].Clear(); | |
- } | |
- | |
- #region Effect File Reader | |
+ internal protected override void GraphicsDeviceResetting() | |
+ { | |
+ foreach (var buffer in ConstantBuffers) | |
+ buffer.Clear(); | |
+ } | |
+ | |
+ #region Effect File Reader | |
internal static byte[] LoadEffectResource(string name) | |
{ | |
@@ -224,6 +221,11 @@ namespace Microsoft.Xna.Framework.Graphics | |
var assembly = typeof(Effect).Assembly; | |
#endif | |
var stream = assembly.GetManifestResourceStream(name); | |
+ if (null == stream) | |
+ { | |
+ throw new InvalidOperationException("Got null manifest resource for " + name); | |
+ } | |
+ | |
using (var ms = new MemoryStream()) | |
{ | |
stream.CopyTo(ms); | |
@@ -289,8 +291,8 @@ namespace Microsoft.Xna.Framework.Graphics | |
var offsets = new int[parameters.Length]; | |
for (var i = 0; i < parameters.Length; i++) | |
{ | |
- parameters [i] = (int)reader.ReadByte (); | |
- offsets [i] = (int)reader.ReadUInt16 (); | |
+ parameters[i] = reader.ReadByte (); | |
+ offsets[i] = reader.ReadUInt16 (); | |
} | |
var buffer = new ConstantBuffer(GraphicsDevice, | |
@@ -359,7 +361,7 @@ namespace Microsoft.Xna.Framework.Graphics | |
// Get the pixel shader. | |
Shader pixelShader = null; | |
- shaderIndex = (int)reader.ReadByte(); | |
+ shaderIndex = reader.ReadByte(); | |
if (shaderIndex != 255) | |
pixelShader = shaders[shaderIndex]; | |
@@ -476,7 +478,7 @@ namespace Microsoft.Xna.Framework.Graphics | |
break; | |
} | |
case EffectParameterType.String: | |
- throw new NotImplementedException(); | |
+ throw new NotImplementedException("EffectParameterType.String"); | |
} | |
} | |
diff --git a/MonoGame.Framework/Graphics/Effect/EffectAnnotationCollection.cs b/MonoGame.Framework/Graphics/Effect/EffectAnnotationCollection.cs | |
old mode 100644 | |
new mode 100755 | |
index 8f8f16a..7381e54 | |
--- a/MonoGame.Framework/Graphics/Effect/EffectAnnotationCollection.cs | |
+++ b/MonoGame.Framework/Graphics/Effect/EffectAnnotationCollection.cs | |
@@ -2,49 +2,30 @@ using System.Collections.Generic; | |
namespace Microsoft.Xna.Framework.Graphics | |
{ | |
- public class EffectAnnotationCollection : IEnumerable<EffectAnnotation> | |
- { | |
- internal static readonly EffectAnnotationCollection Empty = new EffectAnnotationCollection(new EffectAnnotation[0]); | |
+ public class EffectAnnotationCollection : List<EffectAnnotation> | |
+ { | |
+ public EffectAnnotationCollection(IEnumerable<EffectAnnotation> annotations) : base(annotations) | |
+ { | |
+ } | |
+ | |
+ public EffectAnnotationCollection() | |
+ { | |
+ } | |
+ | |
+ internal static readonly EffectAnnotationCollection Empty = new EffectAnnotationCollection(); | |
- private readonly EffectAnnotation[] _annotations; | |
- | |
- internal EffectAnnotationCollection(EffectAnnotation[] annotations) | |
- { | |
- _annotations = annotations; | |
- } | |
- | |
- public int Count | |
- { | |
- get { return _annotations.Length; } | |
- } | |
- | |
- public EffectAnnotation this[int index] | |
- { | |
- get { return _annotations[index]; } | |
- } | |
- | |
public EffectAnnotation this[string name] | |
{ | |
get | |
{ | |
- foreach (var annotation in _annotations) | |
+ foreach (var annotation in this) | |
{ | |
if (annotation.Name == name) | |
return annotation; | |
} | |
return null; | |
} | |
- } | |
- | |
- public IEnumerator<EffectAnnotation> GetEnumerator() | |
- { | |
- return ((IEnumerable<EffectAnnotation>)_annotations).GetEnumerator(); | |
- } | |
- | |
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | |
- { | |
- return _annotations.GetEnumerator(); | |
- } | |
+ } | |
} | |
} | |
diff --git a/MonoGame.Framework/Graphics/Effect/EffectParameterCollection.cs b/MonoGame.Framework/Graphics/Effect/EffectParameterCollection.cs | |
old mode 100644 | |
new mode 100755 | |
index f8096fe..7473f7a | |
--- a/MonoGame.Framework/Graphics/Effect/EffectParameterCollection.cs | |
+++ b/MonoGame.Framework/Graphics/Effect/EffectParameterCollection.cs | |
@@ -2,45 +2,23 @@ | |
namespace Microsoft.Xna.Framework.Graphics | |
{ | |
- public class EffectParameterCollection : IEnumerable<EffectParameter> | |
+ public class EffectParameterCollection : List<EffectParameter> | |
{ | |
- internal static readonly EffectParameterCollection Empty = new EffectParameterCollection(new EffectParameter[0]); | |
+ internal static readonly EffectParameterCollection Empty = new EffectParameterCollection(); | |
- private readonly EffectParameter[] _parameters; | |
- | |
- internal EffectParameterCollection(EffectParameter[] parameters) | |
+ public EffectParameterCollection(IEnumerable<EffectParameter> effectParameters) : base(effectParameters) | |
{ | |
- _parameters = parameters; | |
} | |
- internal EffectParameterCollection Clone() | |
+ public EffectParameterCollection() | |
{ | |
- if (_parameters.Length == 0) | |
- return Empty; | |
- | |
- var parameters = new EffectParameter[_parameters.Length]; | |
- for (var i = 0; i < _parameters.Length; i++) | |
- parameters[i] = new EffectParameter(_parameters[i]); | |
- | |
- return new EffectParameterCollection(parameters); | |
} | |
- public int Count | |
- { | |
- get { return _parameters.Length; } | |
- } | |
- | |
- public EffectParameter this[int index] | |
- { | |
- get { return _parameters[index]; } | |
- } | |
- | |
- public EffectParameter this[string name] | |
+ public EffectParameter this[string name] | |
{ | |
get | |
{ | |
- // TODO: Add a name to parameter lookup table. | |
- foreach (var parameter in _parameters) | |
+ foreach (var parameter in this) | |
{ | |
if (parameter.Name == name) | |
return parameter; | |
@@ -49,15 +27,14 @@ namespace Microsoft.Xna.Framework.Graphics | |
return null; | |
} | |
} | |
- | |
- public IEnumerator<EffectParameter> GetEnumerator() | |
- { | |
- return ((IEnumerable<EffectParameter>)_parameters).GetEnumerator(); | |
- } | |
- | |
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | |
+ | |
+ public EffectParameterCollection Clone() | |
{ | |
- return _parameters.GetEnumerator(); | |
+ var parameters = new EffectParameterCollection(); | |
+ for(var i=0; i < Count; i++) | |
+ parameters.Add(this[i]); | |
+ | |
+ return parameters; | |
} | |
} | |
} | |
diff --git a/MonoGame.Framework/Graphics/Effect/EffectPassCollection.cs b/MonoGame.Framework/Graphics/Effect/EffectPassCollection.cs | |
old mode 100644 | |
new mode 100755 | |
index dd6e374..6689c00 | |
--- a/MonoGame.Framework/Graphics/Effect/EffectPassCollection.cs | |
+++ b/MonoGame.Framework/Graphics/Effect/EffectPassCollection.cs | |
@@ -1,31 +1,24 @@ | |
-using System; | |
-using System.Collections.Generic; | |
-using System.Linq; | |
-using System.Text; | |
+using System.Collections.Generic; | |
namespace Microsoft.Xna.Framework.Graphics | |
{ | |
- public class EffectPassCollection : IEnumerable<EffectPass> | |
+ public class EffectPassCollection : List<EffectPass> | |
{ | |
- private readonly EffectPass[] _passes; | |
- | |
- internal EffectPassCollection(EffectPass [] passes) | |
+ public EffectPassCollection(IEnumerable<EffectPass> passes) : base(passes) | |
{ | |
- _passes = passes; | |
} | |
- internal EffectPassCollection Clone(Effect effect) | |
+ public EffectPassCollection() | |
{ | |
- var passes = new EffectPass[_passes.Length]; | |
- for (var i = 0; i < _passes.Length; i++) | |
- passes[i] = new EffectPass(effect, _passes[i]); | |
- | |
- return new EffectPassCollection(passes); | |
} | |
- public EffectPass this[int index] | |
+ internal EffectPassCollection Clone(Effect effect) | |
{ | |
- get { return _passes[index]; } | |
+ var passes = new EffectPassCollection(); | |
+ for (var i = 0; i < Count; i++) | |
+ passes.Add(new EffectPass(effect, this[i])); | |
+ | |
+ return passes; | |
} | |
public EffectPass this[string name] | |
@@ -33,7 +26,7 @@ namespace Microsoft.Xna.Framework.Graphics | |
get | |
{ | |
// TODO: Add a name to pass lookup table. | |
- foreach (var pass in _passes) | |
+ foreach (var pass in this) | |
{ | |
if (pass.Name == name) | |
return pass; | |
@@ -41,20 +34,5 @@ namespace Microsoft.Xna.Framework.Graphics | |
return null; | |
} | |
} | |
- | |
- public int Count | |
- { | |
- get { return _passes.Length; } | |
- } | |
- | |
- IEnumerator<EffectPass> IEnumerable<EffectPass>.GetEnumerator() | |
- { | |
- return ((IEnumerable<EffectPass>)_passes).GetEnumerator(); | |
- } | |
- | |
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | |
- { | |
- return _passes.GetEnumerator(); | |
- } | |
} | |
} | |
diff --git a/MonoGame.Framework/Graphics/Effect/EffectTechniqueCollection.cs b/MonoGame.Framework/Graphics/Effect/EffectTechniqueCollection.cs | |
old mode 100644 | |
new mode 100755 | |
index 3248735..ddf0ce4 | |
--- a/MonoGame.Framework/Graphics/Effect/EffectTechniqueCollection.cs | |
+++ b/MonoGame.Framework/Graphics/Effect/EffectTechniqueCollection.cs | |
@@ -1,41 +1,32 @@ | |
-using System; | |
-using System.Collections.Generic; | |
-using System.Linq; | |
-using System.Text; | |
+using System.Collections.Generic; | |
namespace Microsoft.Xna.Framework.Graphics | |
{ | |
- public class EffectTechniqueCollection : IEnumerable<EffectTechnique> | |
+ public class EffectTechniqueCollection : List<EffectTechnique> | |
{ | |
- private readonly EffectTechnique[] _techniques; | |
- | |
- public int Count { get { return _techniques.Length; } } | |
+ public EffectTechniqueCollection() | |
+ { | |
+ } | |
- internal EffectTechniqueCollection(EffectTechnique[] techniques) | |
+ public EffectTechniqueCollection(IEnumerable<EffectTechnique> techniques) : base(techniques) | |
{ | |
- _techniques = techniques; | |
} | |
internal EffectTechniqueCollection Clone(Effect effect) | |
{ | |
- var techniques = new EffectTechnique[_techniques.Length]; | |
- for (var i = 0; i < _techniques.Length; i++) | |
- techniques[i] = new EffectTechnique(effect, _techniques[i]); | |
- | |
- return new EffectTechniqueCollection(techniques); | |
+ var techniques = new EffectTechniqueCollection(); | |
+ | |
+ for(var i=0; i < Count; i++) | |
+ techniques.Add(this[i]); | |
+ | |
+ return techniques; | |
} | |
- public EffectTechnique this[int index] | |
- { | |
- get { return _techniques [index]; } | |
- } | |
- | |
public EffectTechnique this[string name] | |
{ | |
get | |
{ | |
- // TODO: Add a name to technique lookup table. | |
- foreach (var technique in _techniques) | |
+ foreach (var technique in this) | |
{ | |
if (technique.Name == name) | |
return technique; | |
@@ -44,15 +35,5 @@ namespace Microsoft.Xna.Framework.Graphics | |
return null; | |
} | |
} | |
- | |
- public IEnumerator<EffectTechnique> GetEnumerator() | |
- { | |
- return ((IEnumerable<EffectTechnique>)_techniques).GetEnumerator(); | |
- } | |
- | |
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | |
- { | |
- return _techniques.GetEnumerator(); | |
- } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment