Browse files

Minor fix, removed dependency on Legacy project which is no longer av…

…ailable.

git-svn-id: http://moq.googlecode.com/svn/trunk@433 b33fba48-7441-0410-8d5c-f397f7ceaa6c
  • Loading branch information...
1 parent 44b4ea9 commit dc3171d98eaf9a398b528b307ede93b296bf4b74 kzu.net committed Jan 21, 2009
Showing with 63 additions and 49 deletions.
  1. +3 −0 Readme.txt
  2. +52 −42 Source/EmptyDefaultValueProvider.cs
  3. +2 −1 Source/Moq.csproj
  4. +0 −1 Source/Properties/AssemblyInfo.cs
  5. +6 −5 UnitTests/Moq.Tests.csproj
View
3 Readme.txt
@@ -0,0 +1,3 @@
+- To skip verification for Moq assembly:
+
+sn -Vr *,69f491c39445e920
View
94 Source/EmptyDefaultValueProvider.cs
@@ -59,53 +59,63 @@ public virtual object ProvideDefault(MethodInfo member, object[] arguments)
// Return default value.
if (valueType.IsValueType)
{
- // For nullable value types, return null.
- if (valueType.IsGenericType &&
- valueType.GetGenericTypeDefinition() == typeof(Nullable<>))
- return null;
- else if (valueType.IsAssignableFrom(typeof(int)))
- return 0;
- else
- return Activator.CreateInstance(valueType);
+ return GetValueTypeDefault(valueType);
}
else
{
- if (valueType.IsArray)
- {
- return Activator.CreateInstance(valueType, 0);
- }
- else if (valueType == typeof(System.Collections.IEnumerable))
- {
- return new object[0];
- }
- else if (valueType == typeof(IQueryable))
- {
- return new object[0].AsQueryable();
- }
- else if (valueType.IsGenericType &&
- valueType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
- {
- var genericListType = typeof(List<>).MakeGenericType(
- valueType.GetGenericArguments()[0]);
- return Activator.CreateInstance(genericListType);
- }
- else if (valueType.IsGenericType &&
- valueType.GetGenericTypeDefinition() == typeof(IQueryable<>))
- {
- var genericType = valueType.GetGenericArguments()[0];
- var genericListType = typeof(List<>).MakeGenericType(genericType);
- var list = Activator.CreateInstance(genericListType);
+ return GetReferenceTypeDefault(valueType);
+ }
+ }
+
+ private static object GetReferenceTypeDefault(Type valueType)
+ {
+ if (valueType.IsArray)
+ {
+ return Activator.CreateInstance(valueType, 0);
+ }
+ else if (valueType == typeof(System.Collections.IEnumerable))
+ {
+ return new object[0];
+ }
+ else if (valueType == typeof(IQueryable))
+ {
+ return new object[0].AsQueryable();
+ }
+ else if (valueType.IsGenericType &&
+ valueType.GetGenericTypeDefinition() == typeof(IEnumerable<>))
+ {
+ var genericListType = typeof(List<>).MakeGenericType(
+ valueType.GetGenericArguments()[0]);
+ return Activator.CreateInstance(genericListType);
+ }
+ else if (valueType.IsGenericType &&
+ valueType.GetGenericTypeDefinition() == typeof(IQueryable<>))
+ {
+ var genericType = valueType.GetGenericArguments()[0];
+ var genericListType = typeof(List<>).MakeGenericType(genericType);
+ var list = Activator.CreateInstance(genericListType);
- return typeof(Queryable).GetMethods()
- .Single(x => x.Name == "AsQueryable" && x.IsGenericMethod)
- .MakeGenericMethod(genericType)
- .Invoke(null, new[] { list });
- }
- else
- {
- return null;
- }
+ return typeof(Queryable).GetMethods()
+ .Single(x => x.Name == "AsQueryable" && x.IsGenericMethod)
+ .MakeGenericMethod(genericType)
+ .Invoke(null, new[] { list });
+ }
+ else
+ {
+ return null;
}
}
+
+ private static object GetValueTypeDefault(Type valueType)
+ {
+ // For nullable value types, return null.
+ if (valueType.IsGenericType &&
+ valueType.GetGenericTypeDefinition() == typeof(Nullable<>))
+ return null;
+ else if (valueType.IsAssignableFrom(typeof(int)))
+ return 0;
+ else
+ return Activator.CreateInstance(valueType);
+ }
}
}
View
3 Source/Moq.csproj
@@ -27,7 +27,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
+ <DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
@@ -37,6 +37,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Design#CA1006;-Microsoft.Design#CA1004;-Microsoft.Maintainability#CA1500;-Microsoft.Naming#CA1704</CodeAnalysisRules>
+ <DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
View
1 Source/Properties/AssemblyInfo.cs
@@ -17,7 +17,6 @@
[assembly: NeutralResourcesLanguage("en")]
[assembly: InternalsVisibleTo("Moq.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001009f7a95086500f8f66d892174803850fed9c22225c2ccfff21f39c8af8abfa5415b1664efd0d8e0a6f7f2513b1c11659bd84723dc7900c3d481b833a73a2bcf1ed94c16c4be64d54352c86956c89930444e9ac15124d3693e3f029818e8410f167399d6b995324b635e95353ba97bfab856abbaeb9b40c9b160070c6325e22ddc")]
-[assembly: InternalsVisibleTo("Moq.Legacy, PublicKey=00240000048000009400000006020000002400005253413100040000010001009f7a95086500f8f66d892174803850fed9c22225c2ccfff21f39c8af8abfa5415b1664efd0d8e0a6f7f2513b1c11659bd84723dc7900c3d481b833a73a2bcf1ed94c16c4be64d54352c86956c89930444e9ac15124d3693e3f029818e8410f167399d6b995324b635e95353ba97bfab856abbaeb9b40c9b160070c6325e22ddc")]
/// <group name="overview" title="Overview" order="0" />
/// <group name="setups" title="Specifying setups" order="1" />
View
11 UnitTests/Moq.Tests.csproj
@@ -25,12 +25,13 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
+ <DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
@@ -44,9 +45,10 @@
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
- <DebugType>pdbonly</DebugType>
+ <DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
+ <DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
@@ -72,7 +74,7 @@
<Reference Include="xunit, Version=1.1.0.1323, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Lib\xUnit\xunit.dll</HintPath>
- <Private>False</Private>
+ <Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -126,8 +128,7 @@
<UsingTask AssemblyFile="$(MSBuildProjectPath)..\Lib\xUnit\xunit.runner.msbuild.dll" TaskName="Xunit.Runner.MSBuild.xunit" />
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
<!-- Run xUnit tests -->
- <Copy SourceFiles="$(MSBuildProjectPath)..\Lib\xUnit\xunit.dll" DestinationFolder="$(OutDir)" />
+ <Copy SourceFiles="$(MSBuildProjectPath)..\Lib\xUnit\xunit.dll" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true" />
<xunit Assembly="@(MainAssembly)" />
- <Delete Files="$(OutDir)\xunit.dll" />
</Target>
</Project>

0 comments on commit dc3171d

Please sign in to comment.