Cosmetic changes.

Fixed some code analysis warnings.
Dropped Extended Strongly Typed Resource Generator dependency.

--HG--
extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4035615
This commit is contained in:
Sean Fausett 2009-12-11 09:12:31 +00:00
parent 8cb42c970d
commit acd7892436
31 changed files with 683 additions and 577 deletions

View File

@ -9,6 +9,11 @@ public static class GCHandleHelpers
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
public static void Pin(object value, Action<IntPtr> action) public static void Pin(object value, Action<IntPtr> action)
{ {
if (action == null)
{
throw new ArgumentNullException("action");
}
GCHandle gcHandle = new GCHandle(); GCHandle gcHandle = new GCHandle();
try try
{ {

View File

@ -127,6 +127,11 @@ public void GetSecurityAttributes(bool inheritable, Action<SecurityAttributes> a
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
public static void GetSecurityAttributes(ObjectSecurity security, bool inheritable, Action<SecurityAttributes> action) public static void GetSecurityAttributes(ObjectSecurity security, bool inheritable, Action<SecurityAttributes> action)
{ {
if (action == null)
{
throw new ArgumentNullException("action");
}
if (security != null) if (security != null)
{ {
GCHandleHelpers.Pin(security.GetSecurityDescriptorBinaryForm(), securityDescriptor => GCHandleHelpers.Pin(security.GetSecurityDescriptorBinaryForm(), securityDescriptor =>

View File

@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")]
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "Jellyfish.Library.FrameRateCounter.#frameRateControl")] [assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "Jellyfish.Library.FrameRateCounter.#frameRateControl")]

View File

@ -7,6 +7,15 @@ public static class IEnumerableExtensions
{ {
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action) public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{ {
if (source == null)
{
throw new ArgumentNullException("source");
}
if (action == null)
{
throw new ArgumentNullException("action");
}
foreach (T item in source) foreach (T item in source)
{ {
action(item); action(item);

View File

@ -42,6 +42,11 @@ public static SafeGlobalAllocHandle Allocate(int size)
public static SafeGlobalAllocHandle Allocate(byte[] value) public static SafeGlobalAllocHandle Allocate(byte[] value)
{ {
if (value == null)
{
throw new ArgumentNullException("value");
}
SafeGlobalAllocHandle alloc = Allocate(value.Length); SafeGlobalAllocHandle alloc = Allocate(value.Length);
Marshal.Copy(value, 0, alloc.DangerousGetHandle(), value.Length); Marshal.Copy(value, 0, alloc.DangerousGetHandle(), value.Length);
@ -100,6 +105,11 @@ public static SafeLocalAllocHandle Allocate(int size)
public static SafeLocalAllocHandle Allocate(byte[] value) public static SafeLocalAllocHandle Allocate(byte[] value)
{ {
if (value == null)
{
throw new ArgumentNullException("value");
}
SafeLocalAllocHandle alloc = Allocate(value.Length); SafeLocalAllocHandle alloc = Allocate(value.Length);
Marshal.Copy(value, 0, alloc.DangerousGetHandle(), value.Length); Marshal.Copy(value, 0, alloc.DangerousGetHandle(), value.Length);

View File

@ -54,6 +54,11 @@ public GeneralSecurity GetAccessControl()
public void SetAccessControl(GeneralSecurity fileSecurity) public void SetAccessControl(GeneralSecurity fileSecurity)
{ {
if (fileSecurity == null)
{
throw new ArgumentNullException("fileSecurity");
}
fileSecurity.Persist(this); fileSecurity.Persist(this);
} }

View File

@ -1,4 +1,5 @@
using System.IO; using System;
using System.IO;
namespace Jellyfish.Library namespace Jellyfish.Library
{ {
@ -6,6 +7,11 @@ public static class StreamExtensions
{ {
public static byte[] ReadAllBytes(this Stream stream) public static byte[] ReadAllBytes(this Stream stream)
{ {
if (stream == null)
{
throw new ArgumentNullException("stream");
}
int count = (int)stream.Length; int count = (int)stream.Length;
byte[] buffer = new byte[count]; byte[] buffer = new byte[count];
ReadBlock(stream, buffer, 0, count); ReadBlock(stream, buffer, 0, count);
@ -15,6 +21,11 @@ public static byte[] ReadAllBytes(this Stream stream)
public static int ReadBlock(this Stream stream, byte[] buffer, int offset, int count) public static int ReadBlock(this Stream stream, byte[] buffer, int offset, int count)
{ {
if (stream == null)
{
throw new ArgumentNullException("stream");
}
int total = 0; int total = 0;
int read; int read;
do do

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")]

View File

@ -42,102 +42,111 @@
</Rules> </Rules>
<FxCopReport Version="1.36"> <FxCopReport Version="1.36">
<Targets> <Targets>
<Target Name="$(ProjectDir)/Wpf/bin/Jellyfish.Virtu.exe">
<Modules>
<Module Name="jellyfish.virtu.exe">
<Namespaces>
<Namespace Name="Jellyfish.Virtu">
<Types>
<Type Name="DiskDsk">
<Members>
<Member Name="#Read3Nibbles(System.Byte,System.Byte,System.Byte,System.Int32)">
<Messages>
<Message Id="nibble" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
<Issue>
<Item>'DiskDsk.Read3Nibbles(byte, byte, byte, int)'</Item>
<Item>'nibble'</Item>
<Item>'byte'</Item>
</Issue>
</Message>
</Messages>
</Member>
<Member Name="#WriteTrack(System.Int32,System.Int32,System.Byte[])">
<Messages>
<Message TypeName="DoNotRaiseReservedExceptionTypes" Category="Microsoft.Usage" CheckId="CA2201" Created="2009-12-11 09:07:49Z">
<Issue Name="TooGeneric">
<Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
<Item>'Exception'</Item>
</Issue>
</Message>
<Message Id="readVolume" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
<Issue>
<Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
<Item>'readVolume'</Item>
<Item>'int'</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
<Type Name="MainWindow">
<Members>
<Member Name="#System.Windows.Markup.IComponentConnector.Connect(System.Int32,System.Object)">
<Messages>
<Message TypeName="DoNotCastUnnecessarily" Category="Microsoft.Performance" CheckId="CA1800" Created="2009-12-11 09:07:49Z">
<Issue Name="Parameter">
<Item>'target'</Item>
<Item>'Button'</Item>
<Item>'MainWindow.IComponentConnector.Connect(int, object)'</Item>
<Item>castclass</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
<Type Name="Video">
<Members>
<Member Name="#ReadFloatingBus()">
<Messages>
<Message TypeName="MarkMembersAsStatic" Category="Microsoft.Performance" CheckId="CA1822" Created="2009-12-11 09:07:49Z" FixCategory="DependsOnFix">
<Issue>
<Item>'Video.ReadFloatingBus()'</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
</Types>
</Namespace>
</Namespaces>
</Module>
</Modules>
</Target>
<Target Name="$(ProjectDir)/Xna/bin/Jellyfish.Virtu.exe"> <Target Name="$(ProjectDir)/Xna/bin/Jellyfish.Virtu.exe">
<Modules> <Modules>
<Module Name="jellyfish.virtu.exe"> <Module Name="jellyfish.virtu.exe">
<Namespaces> <Namespaces>
<Namespace Name="Jellyfish.Virtu"> <Namespace Name="Jellyfish.Virtu">
<Types> <Types>
<Type Name="Disk525"> <Type Name="DiskDsk">
<Messages>
<Message TypeName="AbstractTypesShouldNotHaveConstructors" Category="Microsoft.Design" CheckId="CA1012" Created="2009-04-13 00:02:55Z">
<Issue>
<Item>'Disk525'</Item>
</Issue>
</Message>
</Messages>
<Members> <Members>
<Member Name="#.ctor(System.String,System.Byte[])"> <Member Name="#Read3Nibbles(System.Byte,System.Byte,System.Byte,System.Int32)">
<Messages> <Messages>
<Message Id="fileData" TypeName="ReviewUnusedParameters" Category="Microsoft.Usage" CheckId="CA1801" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix"> <Message Id="nibble" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
<Issue> <Issue>
<Item>'fileData'</Item> <Item>'DiskDsk.Read3Nibbles(byte, byte, byte, int)'</Item>
<Item>'Disk525.Disk525(string, byte[])'</Item> <Item>'nibble'</Item>
</Issue> <Item>'byte'</Item>
</Message>
<Message Id="fileName" TypeName="ReviewUnusedParameters" Category="Microsoft.Usage" CheckId="CA1801" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Issue>
<Item>'fileName'</Item>
<Item>'Disk525.Disk525(string, byte[])'</Item>
</Issue> </Issue>
</Message> </Message>
</Messages> </Messages>
</Member> </Member>
</Members> <Member Name="#WriteTrack(System.Int32,System.Int32,System.Byte[])">
</Type>
<Type Name="DiskII">
<Members>
<Member Name="#_writeModeOn">
<Messages> <Messages>
<Message TypeName="AvoidUnusedPrivateFields" Category="Microsoft.Performance" CheckId="CA1823" Created="2009-04-13 00:02:55Z"> <Message TypeName="DoNotRaiseReservedExceptionTypes" Category="Microsoft.Usage" CheckId="CA2201" Created="2009-12-11 09:07:49Z">
<Issue> <Issue Name="TooGeneric">
<Item>'DiskII._writeModeOn'</Item> <Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
<Item>'Exception'</Item>
</Issue> </Issue>
</Message> </Message>
</Messages> <Message Id="readVolume" TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804" Created="2009-12-11 09:07:49Z">
</Member>
<Member Name="#Write(System.Int32,System.Int32)">
<Messages>
<Message TypeName="MarkMembersAsStatic" Category="Microsoft.Performance" CheckId="CA1822" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Issue> <Issue>
<Item>'DiskII.Write(int, int)'</Item> <Item>'DiskDsk.WriteTrack(int, int, byte[])'</Item>
</Issue> <Item>'readVolume'</Item>
</Message> <Item>'int'</Item>
<Message Id="address" TypeName="ReviewUnusedParameters" Category="Microsoft.Usage" CheckId="CA1801" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Issue>
<Item>'address'</Item>
<Item>'DiskII.Write(int, int)'</Item>
</Issue>
</Message>
<Message Id="data" TypeName="ReviewUnusedParameters" Category="Microsoft.Usage" CheckId="CA1801" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Issue>
<Item>'data'</Item>
<Item>'DiskII.Write(int, int)'</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
<Type Name="Drive525">
<Members>
<Member Name="#driveArmStepDelta">
<Messages>
<Message Id="Member" TypeName="PreferJaggedArraysOverMultidimensional" Category="Microsoft.Performance" CheckId="CA1814" Created="2009-04-13 00:02:55Z">
<Issue>
<Item>'Drive525.driveArmStepDelta'</Item>
</Issue>
</Message>
</Messages>
</Member>
<Member Name="#Reset()">
<Messages>
<Message TypeName="MarkMembersAsStatic" Category="Microsoft.Performance" CheckId="CA1822" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Issue>
<Item>'Drive525.Reset()'</Item>
</Issue>
</Message>
</Messages>
</Member>
</Members>
</Type>
<Type Name="Speaker">
<Members>
<Member Name="#ToggleOutput()">
<Messages>
<Message TypeName="MarkMembersAsStatic" Category="Microsoft.Performance" CheckId="CA1822" Created="2009-04-13 00:02:55Z" FixCategory="DependsOnFix">
<Issue>
<Item>'Speaker.ToggleOutput()'</Item>
</Issue> </Issue>
</Message> </Message>
</Messages> </Messages>
@ -165,20 +174,17 @@
</Target> </Target>
</Targets> </Targets>
<Rules> <Rules>
<Rule TypeName="AbstractTypesShouldNotHaveConstructors" Category="Microsoft.Design" CheckId="CA1012"> <Rule TypeName="DoNotCastUnnecessarily" Category="Microsoft.Performance" CheckId="CA1800">
<Resolution Name="Default">Change the accessibility of all public constructors in {0} to protected.</Resolution> <Resolution Name="Parameter">{0}, a parameter, is cast to type {1} multiple times in method {2}. Cache the result of the 'as' operator or direct cast in order to eliminate the redundant {3} instruction.</Resolution>
</Rule> </Rule>
<Rule TypeName="AvoidUnusedPrivateFields" Category="Microsoft.Performance" CheckId="CA1823"> <Rule TypeName="DoNotRaiseReservedExceptionTypes" Category="Microsoft.Usage" CheckId="CA2201">
<Resolution Name="Default">It appears that field {0} is never used or is only ever assigned to. Use this field or remove it.</Resolution> <Resolution Name="TooGeneric">{0} creates an exception of type {1}, an exception type that is not sufficiently specific and should never be raised by user code. If this exception instance might be thrown, use a different exception type.</Resolution>
</Rule> </Rule>
<Rule TypeName="MarkMembersAsStatic" Category="Microsoft.Performance" CheckId="CA1822"> <Rule TypeName="MarkMembersAsStatic" Category="Microsoft.Performance" CheckId="CA1822">
<Resolution Name="Default">The 'this' parameter (or 'Me' in Visual Basic) of {0} is never used. Mark the member as static (or Shared in Visual Basic) or use 'this'/'Me' in the method body or at least one property accessor, if appropriate.</Resolution> <Resolution Name="Default">The 'this' parameter (or 'Me' in Visual Basic) of {0} is never used. Mark the member as static (or Shared in Visual Basic) or use 'this'/'Me' in the method body or at least one property accessor, if appropriate.</Resolution>
</Rule> </Rule>
<Rule TypeName="PreferJaggedArraysOverMultidimensional" Category="Microsoft.Performance" CheckId="CA1814"> <Rule TypeName="RemoveUnusedLocals" Category="Microsoft.Performance" CheckId="CA1804">
<Resolution Name="Default">{0} is a multidimensional array. Replace it with a jagged array if possible.</Resolution> <Resolution Name="Default">{0} declares a variable, {1}, of type {2}, which is never used or is only assigned to. Use this variable or remove it.</Resolution>
</Rule>
<Rule TypeName="ReviewUnusedParameters" Category="Microsoft.Usage" CheckId="CA1801">
<Resolution Name="Default">Parameter {0} of {1} is never used. Remove the parameter or use it in the method body.</Resolution>
</Rule> </Rule>
</Rules> </Rules>
</FxCopReport> </FxCopReport>

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO; using System.IO;
using System.Resources; using System.Resources;
using Jellyfish.Library; using Jellyfish.Library;
@ -1376,7 +1377,7 @@ private Stream GetRomStream(string romName, int romSize)
Stream romStream = (Stream)resourceManager.GetObject(romName); Stream romStream = (Stream)resourceManager.GetObject(romName);
if (romStream.Length != romSize) if (romStream.Length != romSize)
{ {
throw new InvalidOperationException(SR.RomInvalidFormat(romName)); throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, SR.RomInvalid, romName));
} }
return romStream; return romStream;

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:2.0.50727.4016 // Runtime Version:2.0.50727.4927
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -13,147 +13,78 @@ namespace Jellyfish.Virtu.Properties {
/// <summary> /// <summary>
/// A strongly-typed resource class, for looking up localized strings, formatting them, etc. /// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary> /// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilderEx class via the ResXFileCodeGeneratorEx custom tool. // This class was auto-generated by the StronglyTypedResourceBuilder
// To add or remove a member, edit your .ResX file then rerun the ResXFileCodeGeneratorEx custom tool or rebuild your VS.NET project. // class via a tool like ResGen or Visual Studio.
// Copyright (c) Dmytro Kryvko 2006-2009 (http://dmytro.kryvko.googlepages.com/) // To add or remove a member, edit your .ResX file then rerun ResGen
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("DMKSoftware.CodeGenerators.Tools.StronglyTypedResourceBuilderEx", "2.4.0.0")] // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Naming", "CA1724:TypeNamesShouldNotMatchNamespaces")] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public partial class SR { internal class SR {
private static global::System.Resources.ResourceManager _resourceManager; private static global::System.Resources.ResourceManager resourceMan;
private static object _internalSyncObject; private static global::System.Globalization.CultureInfo resourceCulture;
private static global::System.Globalization.CultureInfo _resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public SR() { internal SR() {
} }
/// <summary> /// <summary>
/// Thread safe lock object used by this class. /// Returns the cached ResourceManager instance used by this class.
/// </summary> /// </summary>
public static object InternalSyncObject { [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(_internalSyncObject, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Threading.Interlocked.CompareExchange(ref _internalSyncObject, new object(), null); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Jellyfish.Virtu.Properties.SR", typeof(SR).Assembly);
resourceMan = temp;
} }
return _internalSyncObject; return resourceMan;
} }
} }
/// <summary> /// <summary>
/// Returns the cached ResourceManager instance used by this class. /// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager { internal static global::System.Globalization.CultureInfo Culture {
get { get {
if (object.ReferenceEquals(_resourceManager, null)) { return resourceCulture;
global::System.Threading.Monitor.Enter(InternalSyncObject);
try {
if (object.ReferenceEquals(_resourceManager, null)) {
global::System.Threading.Interlocked.Exchange(ref _resourceManager, new global::System.Resources.ResourceManager("Jellyfish.Virtu.Properties.SR", typeof(SR).Assembly));
}
}
finally {
global::System.Threading.Monitor.Exit(InternalSyncObject);
}
}
return _resourceManager;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return _resourceCulture;
} }
set { set {
_resourceCulture = value; resourceCulture = value;
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to 'Rom &apos;{0}&apos; invalid.'. /// Looks up a localized string similar to Rom &apos;{0}&apos; invalid..
/// </summary> /// </summary>
public static string RomInvalid { internal static string RomInvalid {
get { get {
return ResourceManager.GetString(ResourceNames.RomInvalid, _resourceCulture); return ResourceManager.GetString("RomInvalid", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to 'Service type &apos;{0}&apos; already present.'. /// Looks up a localized string similar to Service type &apos;{0}&apos; already present..
/// </summary> /// </summary>
public static string ServiceAlreadyPresent { internal static string ServiceAlreadyPresent {
get { get {
return ResourceManager.GetString(ResourceNames.ServiceAlreadyPresent, _resourceCulture); return ResourceManager.GetString("ServiceAlreadyPresent", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to 'Service type &apos;{0}&apos; must be assignable from service provider &apos;{1}&apos;.'. /// Looks up a localized string similar to Service type &apos;{0}&apos; must be assignable from service provider &apos;{1}&apos;..
/// </summary> /// </summary>
public static string ServiceMustBeAssignable { internal static string ServiceMustBeAssignable {
get { get {
return ResourceManager.GetString(ResourceNames.ServiceMustBeAssignable, _resourceCulture); return ResourceManager.GetString("ServiceMustBeAssignable", resourceCulture);
} }
} }
/// <summary>
/// Formats a localized string similar to 'Rom &apos;{0}&apos; invalid.'.
/// </summary>
/// <param name="arg0">An object (0) to format.</param>
/// <returns>A copy of format string in which the format items have been replaced by the String equivalent of the corresponding instances of Object in arguments.</returns>
public static string RomInvalidFormat(object arg0) {
return string.Format(_resourceCulture, RomInvalid, arg0);
}
/// <summary>
/// Formats a localized string similar to 'Service type &apos;{0}&apos; already present.'.
/// </summary>
/// <param name="arg0">An object (0) to format.</param>
/// <returns>A copy of format string in which the format items have been replaced by the String equivalent of the corresponding instances of Object in arguments.</returns>
public static string ServiceAlreadyPresentFormat(object arg0) {
return string.Format(_resourceCulture, ServiceAlreadyPresent, arg0);
}
/// <summary>
/// Formats a localized string similar to 'Service type &apos;{0}&apos; must be assignable from service provider &apos;{1}&apos;.'.
/// </summary>
/// <param name="arg0">An object (0) to format.</param>
/// <param name="arg1">An object (1) to format.</param>
/// <returns>A copy of format string in which the format items have been replaced by the String equivalent of the corresponding instances of Object in arguments.</returns>
public static string ServiceMustBeAssignableFormat(object arg0, object arg1) {
return string.Format(_resourceCulture, ServiceMustBeAssignable, arg0, arg1);
}
/// <summary>
/// Lists all the resource names as constant string fields.
/// </summary>
public class ResourceNames {
/// <summary>
/// Stores the resource name 'RomInvalid'.
/// </summary>
public const string RomInvalid = "RomInvalid";
/// <summary>
/// Stores the resource name 'ServiceAlreadyPresent'.
/// </summary>
public const string ServiceAlreadyPresent = "ServiceAlreadyPresent";
/// <summary>
/// Stores the resource name 'ServiceMustBeAssignable'.
/// </summary>
public const string ServiceMustBeAssignable = "ServiceMustBeAssignable";
}
} }
} }

View File

@ -25,6 +25,11 @@ public void ToggleOutput() // machine thread
protected void Update(int bufferSize, Action<byte[], int> updateBuffer) // audio thread protected void Update(int bufferSize, Action<byte[], int> updateBuffer) // audio thread
{ {
if (updateBuffer == null)
{
throw new ArgumentNullException("updateBuffer");
}
lock (_lock) lock (_lock)
{ {
long cycles = Machine.Cpu.Cycles; long cycles = Machine.Cpu.Cycles;

View File

@ -6,6 +6,11 @@ public abstract class MachineService : IDisposable
{ {
protected MachineService(Machine machine) protected MachineService(Machine machine)
{ {
if (machine == null)
{
throw new ArgumentNullException("machine");
}
Machine = machine; Machine = machine;
} }

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Jellyfish.Virtu.Properties; using Jellyfish.Virtu.Properties;
namespace Jellyfish.Virtu.Services namespace Jellyfish.Virtu.Services
@ -9,13 +10,21 @@ public sealed class MachineServices : IServiceProvider
{ {
public void AddService(Type serviceType, MachineService serviceProvider) public void AddService(Type serviceType, MachineService serviceProvider)
{ {
if (serviceType == null)
{
throw new ArgumentNullException("serviceType");
}
if (_serviceProviders.ContainsKey(serviceType)) if (_serviceProviders.ContainsKey(serviceType))
{ {
throw new ArgumentException(SR.ServiceAlreadyPresentFormat(serviceType.FullName), "serviceType"); throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ServiceAlreadyPresent, serviceType.FullName), "serviceType");
}
if (serviceProvider == null)
{
throw new ArgumentNullException("serviceProvider");
} }
if (!serviceType.IsAssignableFrom(serviceProvider.GetType())) if (!serviceType.IsAssignableFrom(serviceProvider.GetType()))
{ {
throw new ArgumentException(SR.ServiceMustBeAssignableFormat(serviceType.FullName, serviceProvider.GetType().FullName)); throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ServiceMustBeAssignable, serviceType.FullName, serviceProvider.GetType().FullName));
} }
_serviceProviders.Add(serviceType, serviceProvider); _serviceProviders.Add(serviceType, serviceProvider);

View File

@ -95,6 +95,9 @@
<Compile Include="..\GamePort.cs"> <Compile Include="..\GamePort.cs">
<Link>Core\GamePort.cs</Link> <Link>Core\GamePort.cs</Link>
</Compile> </Compile>
<Compile Include="..\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<Compile Include="..\Keyboard.cs"> <Compile Include="..\Keyboard.cs">
<Link>Core\Keyboard.cs</Link> <Link>Core\Keyboard.cs</Link>
</Compile> </Compile>
@ -186,7 +189,7 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="..\Properties\SR.resx"> <EmbeddedResource Include="..\Properties\SR.resx">
<Link>Properties\SR.resx</Link> <Link>Properties\SR.resx</Link>
<Generator>ResXFileCodeGeneratorEx</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>SR.Designer.cs</LastGenOutput> <LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>

View File

@ -1,4 +1,5 @@
using System.Windows.Controls; using System;
using System.Windows.Controls;
namespace Jellyfish.Virtu.Services namespace Jellyfish.Virtu.Services
{ {
@ -7,6 +8,15 @@ public sealed class SilverlightAudioService : AudioService
public SilverlightAudioService(Machine machine, UserControl page, MediaElement media) : public SilverlightAudioService(Machine machine, UserControl page, MediaElement media) :
base(machine) base(machine)
{ {
if (page == null)
{
throw new ArgumentNullException("page");
}
if (media == null)
{
throw new ArgumentNullException("media");
}
_page = page; _page = page;
_media = media; _media = media;

View File

@ -12,6 +12,11 @@ public sealed class SilverlightKeyboardService : KeyboardService
public SilverlightKeyboardService(Machine machine, UserControl page) : public SilverlightKeyboardService(Machine machine, UserControl page) :
base(machine) base(machine)
{ {
if (page == null)
{
throw new ArgumentNullException("page");
}
_page = page; _page = page;
_page.KeyDown += Page_KeyDown; _page.KeyDown += Page_KeyDown;

View File

@ -13,6 +13,11 @@ public SilverlightStorageService(Machine machine) :
public override void Load(string path, Action<Stream> reader) public override void Load(string path, Action<Stream> reader)
{ {
if (reader == null)
{
throw new ArgumentNullException("reader");
}
try try
{ {
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
@ -33,6 +38,11 @@ public override void Load(string path, Action<Stream> reader)
public override void Save(string path, Action<Stream> writer) public override void Save(string path, Action<Stream> writer)
{ {
if (writer == null)
{
throw new ArgumentNullException("writer");
}
try try
{ {
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())

View File

@ -12,7 +12,13 @@ public sealed class SilverlightVideoService : VideoService
public SilverlightVideoService(Machine machine, Image image) : public SilverlightVideoService(Machine machine, Image image) :
base(machine) base(machine)
{ {
if (image == null)
{
throw new ArgumentNullException("image");
}
_image = image; _image = image;
_image.Source = _bitmap; _image.Source = _bitmap;
SetImageSize(); SetImageSize();

View File

@ -111,6 +111,9 @@
<Compile Include="..\GamePort.cs"> <Compile Include="..\GamePort.cs">
<Link>Core\GamePort.cs</Link> <Link>Core\GamePort.cs</Link>
</Compile> </Compile>
<Compile Include="..\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<Compile Include="..\Services\AudioService.cs"> <Compile Include="..\Services\AudioService.cs">
<Link>Services\AudioService.cs</Link> <Link>Services\AudioService.cs</Link>
</Compile> </Compile>
@ -189,7 +192,7 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="..\Properties\SR.resx"> <EmbeddedResource Include="..\Properties\SR.resx">
<Link>Properties\SR.resx</Link> <Link>Properties\SR.resx</Link>
<Generator>ResXFileCodeGeneratorEx</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>SR.Designer.cs</LastGenOutput> <LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>

View File

@ -15,7 +15,7 @@ public MainWindow()
_storageService = new WpfStorageService(_machine); _storageService = new WpfStorageService(_machine);
_keyboardService = new WpfKeyboardService(_machine, this); _keyboardService = new WpfKeyboardService(_machine, this);
_gamePortService = new XnaGamePortService(_machine); _gamePortService = new GamePortService(_machine); // not connected
_audioService = new WpfAudioService(_machine, this); _audioService = new WpfAudioService(_machine, this);
_videoService = new WpfVideoService(_machine, this, _image); _videoService = new WpfVideoService(_machine, this, _image);

View File

@ -10,6 +10,11 @@ public sealed class WpfAudioService : AudioService
public WpfAudioService(Machine machine, Window window) : public WpfAudioService(Machine machine, Window window) :
base(machine) base(machine)
{ {
if (window == null)
{
throw new ArgumentNullException("window");
}
_window = window; _window = window;
_window.SourceInitialized += (sender, e) => _directSound.Start(_window.GetHandle()); _window.SourceInitialized += (sender, e) => _directSound.Start(_window.GetHandle());
@ -23,6 +28,8 @@ protected override void Dispose(bool disposing)
{ {
_directSound.Dispose(); _directSound.Dispose();
} }
base.Dispose(disposing);
} }
private void DirectSound_Update(object sender, DirectSoundUpdateEventArgs e) private void DirectSound_Update(object sender, DirectSoundUpdateEventArgs e)

View File

@ -11,6 +11,11 @@ public sealed class WpfKeyboardService : KeyboardService
public WpfKeyboardService(Machine machine, Window window) : public WpfKeyboardService(Machine machine, Window window) :
base(machine) base(machine)
{ {
if (window == null)
{
throw new ArgumentNullException("window");
}
_window = window; _window = window;
_window.KeyDown += Window_KeyDown; _window.KeyDown += Window_KeyDown;

View File

@ -14,6 +14,11 @@ public WpfStorageService(Machine machine) :
public override void Load(string path, Action<Stream> reader) public override void Load(string path, Action<Stream> reader)
{ {
if (reader == null)
{
throw new ArgumentNullException("reader");
}
try try
{ {
using (IsolatedStorageFile store = GetStore()) using (IsolatedStorageFile store = GetStore())
@ -34,6 +39,11 @@ public override void Load(string path, Action<Stream> reader)
public override void Save(string path, Action<Stream> writer) public override void Save(string path, Action<Stream> writer)
{ {
if (writer == null)
{
throw new ArgumentNullException("writer");
}
try try
{ {
using (IsolatedStorageFile store = GetStore()) using (IsolatedStorageFile store = GetStore())

View File

@ -15,8 +15,18 @@ public sealed class WpfVideoService : VideoService
public WpfVideoService(Machine machine, Window window, Image image) : public WpfVideoService(Machine machine, Window window, Image image) :
base(machine) base(machine)
{ {
if (window == null)
{
throw new ArgumentNullException("window");
}
if (image == null)
{
throw new ArgumentNullException("image");
}
_window = window; _window = window;
_image = image; _image = image;
_image.Source = _bitmap; _image.Source = _bitmap;
SetImageSize(); SetImageSize();

View File

@ -92,6 +92,9 @@
<Compile Include="..\GamePort.cs"> <Compile Include="..\GamePort.cs">
<Link>Core\GamePort.cs</Link> <Link>Core\GamePort.cs</Link>
</Compile> </Compile>
<Compile Include="..\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<Compile Include="..\Keyboard.cs"> <Compile Include="..\Keyboard.cs">
<Link>Core\Keyboard.cs</Link> <Link>Core\Keyboard.cs</Link>
</Compile> </Compile>
@ -211,7 +214,7 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="..\Properties\SR.resx"> <EmbeddedResource Include="..\Properties\SR.resx">
<Link>Properties\SR.resx</Link> <Link>Properties\SR.resx</Link>
<Generator>ResXFileCodeGeneratorEx</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>SR.Designer.cs</LastGenOutput> <LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>

View File

@ -113,6 +113,9 @@
<Compile Include="..\GamePort.cs"> <Compile Include="..\GamePort.cs">
<Link>Core\GamePort.cs</Link> <Link>Core\GamePort.cs</Link>
</Compile> </Compile>
<Compile Include="..\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<Compile Include="..\Keyboard.cs"> <Compile Include="..\Keyboard.cs">
<Link>Core\Keyboard.cs</Link> <Link>Core\Keyboard.cs</Link>
</Compile> </Compile>
@ -225,7 +228,7 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="..\Properties\SR.resx"> <EmbeddedResource Include="..\Properties\SR.resx">
<Link>Properties\SR.resx</Link> <Link>Properties\SR.resx</Link>
<Generator>ResXFileCodeGeneratorEx</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>SR.Designer.cs</LastGenOutput> <LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>

View File

@ -10,6 +10,11 @@ public sealed class XnaAudioService : AudioService
public XnaAudioService(Machine machine, GameBase game) : public XnaAudioService(Machine machine, GameBase game) :
base(machine) base(machine)
{ {
if (game == null)
{
throw new ArgumentNullException("game");
}
_game = game; _game = game;
_directSound.Start(_game.Window.Handle); _directSound.Start(_game.Window.Handle);

View File

@ -11,11 +11,21 @@ public sealed class XnaStorageService : StorageService
public XnaStorageService(Machine machine, GameBase game) : public XnaStorageService(Machine machine, GameBase game) :
base(machine) base(machine)
{ {
if (game == null)
{
throw new ArgumentNullException("game");
}
_game = game; _game = game;
} }
public override void Load(string path, Action<Stream> reader) public override void Load(string path, Action<Stream> reader)
{ {
if (reader == null)
{
throw new ArgumentNullException("reader");
}
try try
{ {
using (StorageContainer storageContainer = _storageDevice.Value.OpenContainer(_game.Name)) using (StorageContainer storageContainer = _storageDevice.Value.OpenContainer(_game.Name))
@ -33,6 +43,11 @@ public override void Load(string path, Action<Stream> reader)
public override void Save(string path, Action<Stream> writer) public override void Save(string path, Action<Stream> writer)
{ {
if (writer == null)
{
throw new ArgumentNullException("writer");
}
using (StorageContainer storageContainer = _storageDevice.Value.OpenContainer(_game.Name)) using (StorageContainer storageContainer = _storageDevice.Value.OpenContainer(_game.Name))
{ {
using (FileStream stream = new FileStream(Path.Combine(storageContainer.Path, path), FileMode.Create, FileAccess.Write, FileShare.None)) using (FileStream stream = new FileStream(Path.Combine(storageContainer.Path, path), FileMode.Create, FileAccess.Write, FileShare.None))

View File

@ -11,6 +11,11 @@ public sealed class XnaVideoService : VideoService
public XnaVideoService(Machine machine, GameBase game) : public XnaVideoService(Machine machine, GameBase game) :
base(machine) base(machine)
{ {
if (game == null)
{
throw new ArgumentNullException("game");
}
_game = game; _game = game;
_game.GraphicsDeviceManager.PreparingDeviceSettings += GraphicsDeviceManager_PreparingDeviceSettings; _game.GraphicsDeviceManager.PreparingDeviceSettings += GraphicsDeviceManager_PreparingDeviceSettings;