Skip to content

Commit 83b3513

Browse files
committed
Refresh NuGet references, minor changes and fixes
1 parent 4e85de4 commit 83b3513

11 files changed

+101
-107
lines changed

ProductionPlanning/ProductionPlanning.Logic/ImmutableHelpers.cs

-54
This file was deleted.

ProductionPlanning/ProductionPlanning.Logic/ImmutableProduct.cs

+15-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace ProductionPlanning.Logic
77
{
8-
using ProductRepository = IEnumerable<ImmutableProduct>;
8+
using IProductRepository = IEnumerable<ImmutableProduct>;
99

1010
/// <summary>
1111
/// Implements an immutable product
@@ -43,14 +43,14 @@ public ImmutableProduct(Guid productID, string description, decimal costsPerItem
4343
/// </summary>
4444
public class ImmutableCompositeProduct : ImmutableProduct, ICompositeProduct
4545
{
46-
public ImmutableCompositeProduct(ICompositeProduct source, ProductRepository productRepository)
46+
public ImmutableCompositeProduct(ICompositeProduct source, IProductRepository productRepository)
4747
: this(source.ProductID, source.Description, source.CostsPerItem,
4848
source.Parts, productRepository)
4949
{ }
5050

5151
public ImmutableCompositeProduct(Guid productID, string description,
5252
decimal costsPerItem, IEnumerable<IPart> parts,
53-
ProductRepository productRepository)
53+
IProductRepository productRepository)
5454
: base(productID, description, costsPerItem)
5555
{
5656
#region Check preconditions
@@ -65,7 +65,15 @@ public ImmutableCompositeProduct(Guid productID, string description,
6565
throw new ArgumentNullException(nameof(parts));
6666
}
6767

68-
if (parts.Count() == 0)
68+
// Note the use of .NET 4.6's new AppContext class.
69+
bool supportsCompositeProductsWithouthParts;
70+
if (!AppContext.TryGetSwitch("Switch.ProductionPlanning.SupportCompositeProductsWithouthParts", out supportsCompositeProductsWithouthParts))
71+
{
72+
// If no opt-in -> do not support composite products without parts
73+
supportsCompositeProductsWithouthParts = false;
74+
}
75+
76+
if (parts.Count() == 0 && !supportsCompositeProductsWithouthParts)
6977
{
7078
throw new ArgumentException(
7179
@"Parts must not be empty for an immutable composite product.
@@ -111,7 +119,7 @@ public ImmutableCompositeProduct(Guid productID, string description,
111119
/// </summary>
112120
public class ImmutablePart : IPart
113121
{
114-
public ImmutablePart(Guid productID, int amount, ProductRepository productRepository)
122+
public ImmutablePart(Guid productID, int amount, IProductRepository productRepository)
115123
{
116124
#region Check preconditions
117125
if (productRepository == null)
@@ -134,8 +142,8 @@ public ImmutablePart(Guid productID, int amount, ProductRepository productReposi
134142

135143
public ImmutableProduct Part { get; }
136144

137-
// Note implicit interface implementation with function-bodied property
138-
Guid IPart.ComponentProductID => this.Part.ProductID;
145+
// Note interface implementation with function-bodied property
146+
public Guid ComponentProductID => this.Part.ProductID;
139147

140148
public int Amount { get; }
141149
}

ProductionPlanning/ProductionPlanning.Logic/ProductionPlanning.Logic.csproj

+22-16
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
5-
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
65
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
76
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8-
<ProjectGuid>{D8208B65-B17B-4310-A284-B19C1B1C8E09}</ProjectGuid>
7+
<ProjectGuid>{89C33F23-58E7-49EB-ACF1-5CDDFF96EF81}</ProjectGuid>
98
<OutputType>Library</OutputType>
109
<AppDesignerFolder>Properties</AppDesignerFolder>
1110
<RootNamespace>ProductionPlanning.Logic</RootNamespace>
1211
<AssemblyName>ProductionPlanning.Logic</AssemblyName>
13-
<DefaultLanguage>en-US</DefaultLanguage>
12+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
1413
<FileAlignment>512</FileAlignment>
15-
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
16-
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
17-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1814
</PropertyGroup>
1915
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2016
<DebugSymbols>true</DebugSymbols>
@@ -24,8 +20,6 @@
2420
<DefineConstants>DEBUG;TRACE</DefineConstants>
2521
<ErrorReport>prompt</ErrorReport>
2622
<WarningLevel>4</WarningLevel>
27-
<RunCodeAnalysis>false</RunCodeAnalysis>
28-
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
2923
</PropertyGroup>
3024
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3125
<DebugType>pdbonly</DebugType>
@@ -35,24 +29,36 @@
3529
<ErrorReport>prompt</ErrorReport>
3630
<WarningLevel>4</WarningLevel>
3731
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="System" />
34+
<Reference Include="System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
35+
<HintPath>..\packages\System.Collections.Immutable.1.1.37\lib\dotnet\System.Collections.Immutable.dll</HintPath>
36+
<Private>True</Private>
37+
</Reference>
38+
<Reference Include="System.ComponentModel.DataAnnotations" />
39+
<Reference Include="System.Core" />
40+
<Reference Include="System.Xml.Linq" />
41+
<Reference Include="System.Data.DataSetExtensions" />
42+
<Reference Include="Microsoft.CSharp" />
43+
<Reference Include="System.Data" />
44+
<Reference Include="System.Net.Http" />
45+
<Reference Include="System.Xml" />
46+
</ItemGroup>
3847
<ItemGroup>
3948
<Compile Include="BindableBase.cs" />
49+
<Compile Include="ImmutableProduct.cs" />
4050
<Compile Include="ImmutableProductRepository.cs" />
4151
<Compile Include="IProduct.cs" />
42-
<Compile Include="ImmutableProduct.cs" />
4352
<Compile Include="Product.cs" />
4453
<Compile Include="Properties\AssemblyInfo.cs" />
4554
</ItemGroup>
4655
<ItemGroup>
47-
<Reference Include="System.Collections.Immutable">
48-
<HintPath>..\packages\System.Collections.Immutable.1.1.33-beta\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
49-
</Reference>
50-
</ItemGroup>
51-
<ItemGroup>
52-
<None Include="packages.config" />
56+
<None Include="packages.config">
57+
<SubType>Designer</SubType>
58+
</None>
5359
<None Include="ProductionPlanning.cd" />
5460
</ItemGroup>
55-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
61+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
5662
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
5763
Other similar extension points exist, see Microsoft.Common.targets.
5864
<Target Name="BeforeBuild">

ProductionPlanning/ProductionPlanning.Logic/Properties/AssemblyInfo.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Resources;
2-
using System.Reflection;
1+
using System.Reflection;
32
using System.Runtime.CompilerServices;
43
using System.Runtime.InteropServices;
54

@@ -14,7 +13,14 @@
1413
[assembly: AssemblyCopyright("Copyright © 2015")]
1514
[assembly: AssemblyTrademark("")]
1615
[assembly: AssemblyCulture("")]
17-
[assembly: NeutralResourcesLanguage("en")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("89c33f23-58e7-49eb-acf1-5cddff96ef81")]
1824

1925
// Version information for an assembly consists of the following four values:
2026
//
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="System.Collections.Immutable" version="1.1.33-beta" targetFramework="portable-net45+win" />
3+
<package id="System.Collections" version="4.0.10" targetFramework="net46" />
4+
<package id="System.Collections.Immutable" version="1.1.37" targetFramework="net46" />
5+
<package id="System.Diagnostics.Debug" version="4.0.10" targetFramework="net46" />
6+
<package id="System.Globalization" version="4.0.10" targetFramework="net46" />
7+
<package id="System.Linq" version="4.0.0" targetFramework="net46" />
8+
<package id="System.Resources.ResourceManager" version="4.0.0" targetFramework="net46" />
9+
<package id="System.Runtime" version="4.0.20" targetFramework="net46" />
10+
<package id="System.Runtime.Extensions" version="4.0.10" targetFramework="net46" />
11+
<package id="System.Threading" version="4.0.10" targetFramework="net46" />
412
</packages>

ProductionPlanning/ProductionPlanning.Tests/ProductionPlanning.Tests.csproj

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProjectGuid>{C66C4B17-01B2-49B2-862B-5CFDB9B9BCEC}</ProjectGuid>
6+
<ProjectGuid>{62EA1918-C621-4814-8624-3E1CFF424F2D}</ProjectGuid>
77
<OutputType>Library</OutputType>
88
<AppDesignerFolder>Properties</AppDesignerFolder>
99
<RootNamespace>ProductionPlanning.Tests</RootNamespace>
1010
<AssemblyName>ProductionPlanning.Tests</AssemblyName>
11-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
11+
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
1313
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1414
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
@@ -36,9 +36,9 @@
3636
</PropertyGroup>
3737
<ItemGroup>
3838
<Reference Include="System" />
39-
<Reference Include="System.Collections.Immutable, Version=1.1.33.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
40-
<SpecificVersion>False</SpecificVersion>
41-
<HintPath>..\packages\System.Collections.Immutable.1.1.33-beta\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
39+
<Reference Include="System.Collections.Immutable, Version=1.1.37.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
40+
<HintPath>..\packages\System.Collections.Immutable.1.1.37\lib\dotnet\System.Collections.Immutable.dll</HintPath>
41+
<Private>True</Private>
4242
</Reference>
4343
</ItemGroup>
4444
<Choose>
@@ -55,21 +55,21 @@
5555
</Choose>
5656
<ItemGroup>
5757
<Compile Include="AssertNotification.cs" />
58+
<Compile Include="Properties\AssemblyInfo.cs" />
5859
<Compile Include="TestImmutablePart.cs" />
59-
<Compile Include="TestImmutableProductRepository.cs" />
6060
<Compile Include="TestImmutableProduct.cs" />
61+
<Compile Include="TestImmutableProductRepository.cs" />
6162
<Compile Include="TestProduct.cs" />
62-
<Compile Include="Properties\AssemblyInfo.cs" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<None Include="packages.config" />
6366
</ItemGroup>
6467
<ItemGroup>
6568
<ProjectReference Include="..\ProductionPlanning.Logic\ProductionPlanning.Logic.csproj">
66-
<Project>{d8208b65-b17b-4310-a284-b19c1b1c8e09}</Project>
69+
<Project>{89c33f23-58e7-49eb-acf1-5cddff96ef81}</Project>
6770
<Name>ProductionPlanning.Logic</Name>
6871
</ProjectReference>
6972
</ItemGroup>
70-
<ItemGroup>
71-
<None Include="packages.config" />
72-
</ItemGroup>
7373
<Choose>
7474
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
7575
<ItemGroup>

ProductionPlanning/ProductionPlanning.Tests/Properties/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
[assembly: ComVisible(false)]
2121

2222
// The following GUID is for the ID of the typelib if this project is exposed to COM
23-
[assembly: Guid("c66c4b17-01b2-49b2-862b-5cfdb9b9bcec")]
23+
[assembly: Guid("62ea1918-c621-4814-8624-3e1cff424f2d")]
2424

2525
// Version information for an assembly consists of the following four values:
2626
//

ProductionPlanning/ProductionPlanning.Tests/TestImmutablePart.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void TestMissingProductID()
1818
new ImmutablePart(productID, 5, new List<ImmutableProduct>());
1919
}
2020
// Note new exception handling condition here
21-
catch (ArgumentException ex) if (!ex.Message.Contains(productID.ToString()))
21+
catch (ArgumentException ex) when (!ex.Message.Contains(productID.ToString()))
2222
{
2323
// Suppress exception if message is not correct
2424
}

ProductionPlanning/ProductionPlanning.Tests/TestImmutableProduct.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void TestProductCreation()
1616
var ip = new ImmutableProduct(Guid.NewGuid(), "Test", 1M);
1717
Assert.IsNotNull(ip);
1818

19-
// Create an immutable composite product. Not that both parts
19+
// Create an immutable composite product. Note that both parts
2020
// refer to the same product. Therefore the ImmutableProduct
2121
// object has to be reused.
2222
var icp = new ImmutableCompositeProduct(
@@ -67,6 +67,18 @@ public void TestRepositoryNullException()
6767
[ExpectedException(typeof(ArgumentException))]
6868
public void TestCompositeProductWithoutPartsException()
6969
{
70+
// Try to create a composite product without parts
71+
new ImmutableCompositeProduct(Guid.NewGuid(), "Test", 1M,
72+
new List<Part>(), new List<ImmutableProduct>());
73+
}
74+
75+
[TestMethod]
76+
public void TestCompositeProductWithoutPartsWithoutException()
77+
{
78+
// Opt-in to support of composite products without parts
79+
AppContext.SetSwitch("Switch.ProductionPlanning.SupportCompositeProductsWithouthParts", true);
80+
81+
// Try to create a composite product without parts
7082
new ImmutableCompositeProduct(Guid.NewGuid(), "Test", 1M,
7183
new List<Part>(), new List<ImmutableProduct>());
7284
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="System.Collections.Immutable" version="1.1.33-beta" targetFramework="net45" />
3+
<package id="System.Collections" version="4.0.10" targetFramework="net46" />
4+
<package id="System.Collections.Immutable" version="1.1.37" targetFramework="net46" />
5+
<package id="System.Diagnostics.Debug" version="4.0.10" targetFramework="net46" />
6+
<package id="System.Globalization" version="4.0.10" targetFramework="net46" />
7+
<package id="System.Linq" version="4.0.0" targetFramework="net46" />
8+
<package id="System.Resources.ResourceManager" version="4.0.0" targetFramework="net46" />
9+
<package id="System.Runtime" version="4.0.20" targetFramework="net46" />
10+
<package id="System.Runtime.Extensions" version="4.0.10" targetFramework="net46" />
11+
<package id="System.Threading" version="4.0.10" targetFramework="net46" />
412
</packages>

ProductionPlanning/ProductionPlanning.sln

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.22512.0
4+
VisualStudioVersion = 14.0.23107.0
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductionPlanning.Logic", "ProductionPlanning.Logic\ProductionPlanning.Logic.csproj", "{D8208B65-B17B-4310-A284-B19C1B1C8E09}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductionPlanning.Tests", "ProductionPlanning.Tests\ProductionPlanning.Tests.csproj", "{62EA1918-C621-4814-8624-3E1CFF424F2D}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductionPlanning.Tests", "ProductionPlanning.Tests\ProductionPlanning.Tests.csproj", "{C66C4B17-01B2-49B2-862B-5CFDB9B9BCEC}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductionPlanning.Logic", "ProductionPlanning.Logic\ProductionPlanning.Logic.csproj", "{89C33F23-58E7-49EB-ACF1-5CDDFF96EF81}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1212
Debug|Any CPU = Debug|Any CPU
1313
Release|Any CPU = Release|Any CPU
1414
EndGlobalSection
1515
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{D8208B65-B17B-4310-A284-B19C1B1C8E09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17-
{D8208B65-B17B-4310-A284-B19C1B1C8E09}.Debug|Any CPU.Build.0 = Debug|Any CPU
18-
{D8208B65-B17B-4310-A284-B19C1B1C8E09}.Release|Any CPU.ActiveCfg = Release|Any CPU
19-
{D8208B65-B17B-4310-A284-B19C1B1C8E09}.Release|Any CPU.Build.0 = Release|Any CPU
20-
{C66C4B17-01B2-49B2-862B-5CFDB9B9BCEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21-
{C66C4B17-01B2-49B2-862B-5CFDB9B9BCEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
22-
{C66C4B17-01B2-49B2-862B-5CFDB9B9BCEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{C66C4B17-01B2-49B2-862B-5CFDB9B9BCEC}.Release|Any CPU.Build.0 = Release|Any CPU
16+
{62EA1918-C621-4814-8624-3E1CFF424F2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{62EA1918-C621-4814-8624-3E1CFF424F2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{62EA1918-C621-4814-8624-3E1CFF424F2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{62EA1918-C621-4814-8624-3E1CFF424F2D}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{89C33F23-58E7-49EB-ACF1-5CDDFF96EF81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{89C33F23-58E7-49EB-ACF1-5CDDFF96EF81}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{89C33F23-58E7-49EB-ACF1-5CDDFF96EF81}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{89C33F23-58E7-49EB-ACF1-5CDDFF96EF81}.Release|Any CPU.Build.0 = Release|Any CPU
2424
EndGlobalSection
2525
GlobalSection(SolutionProperties) = preSolution
2626
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)