Skip to content

Commit 7edc7a1

Browse files
authored
Merge pull request #44 from godrose/fb-use-single-assemblies-source
Fb use single assemblies source
2 parents 656f6ea + 55158eb commit 7edc7a1

40 files changed

Lines changed: 533 additions & 393 deletions

File tree

Solid.Bootstrapping/Solid.Bootstrapping.csproj

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<AssemblyName>Solid.Bootstrapping</AssemblyName>
6-
<RootNamespace>Solid.Bootstrapping</RootNamespace>
7-
<AssemblyVersion>2.0.0.0</AssemblyVersion>
8-
<FileVersion>2.0.0.0</FileVersion>
9-
</PropertyGroup>
10-
11-
<PropertyGroup>
125
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
13-
<Version>2.0.0</Version>
6+
<Version>2.1.0</Version>
147
</PropertyGroup>
158

169
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">

Solid.Common.Platform/net/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("2.0.0")]
35-
[assembly: AssemblyFileVersion("2.0.0")]
34+
[assembly: AssemblyVersion("2.1.0")]
35+
[assembly: AssemblyFileVersion("2.1.0")]

Solid.Common.Platform/uwp/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
// You can specify all the values or you can default the Build and Revision Numbers
2424
// by using the '*' as shown below:
2525
// [assembly: AssemblyVersion("1.0.*")]
26-
[assembly: AssemblyVersion("2.0.0.0")]
27-
[assembly: AssemblyFileVersion("2.0.0.0")]
26+
[assembly: AssemblyVersion("2.1.0.0")]
27+
[assembly: AssemblyFileVersion("2.1.0.0")]
2828
[assembly: ComVisible(false)]

Solid.Common/Solid.Common.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
</PropertyGroup>
6-
7-
<PropertyGroup>
85
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
9-
<Version>2.0.0</Version>
10-
<RootNamespace>Solid.Common</RootNamespace>
6+
<Version>2.1.0</Version>
117
</PropertyGroup>
128

139
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using FluentAssertions;
4+
using Xunit;
5+
6+
namespace Solid.Core.Tests
7+
{
8+
public class PatternsCalculatorTests
9+
{
10+
public class InputData
11+
{
12+
public InputData(string[] prefixes, string[] namespaces, string[] extensions)
13+
{
14+
Prefixes = prefixes;
15+
Namespaces = namespaces;
16+
Extensions = extensions;
17+
}
18+
19+
public string[] Prefixes { get; }
20+
public string[] Namespaces { get; }
21+
public string[] Extensions { get; }
22+
}
23+
24+
public static IEnumerable<object[]> NonEmptyCollectionsData =>
25+
new List<object[]>
26+
{
27+
new object[]
28+
{
29+
new InputData(new[] {"Prefix"}, new[] {"Namespace"}, new[] {"ext"}),
30+
new[] {new PatternDescription("Prefix", "Namespace", "ext")}
31+
},
32+
new object[]
33+
{
34+
new InputData(new[] {"Prefix"}, new[] {"Namespace1", "Namespace2"}, new[] {"ext"}),
35+
new[]
36+
{
37+
new PatternDescription("Prefix", "Namespace1", "ext"),
38+
new PatternDescription("Prefix", "Namespace2", "ext")
39+
}
40+
},
41+
new object[]
42+
{
43+
new InputData(new[] {"Prefix"}, new[] {"Namespace1", "Namespace2"}, new[] {"ext1", "ext2"}),
44+
new[]
45+
{
46+
new PatternDescription("Prefix", "Namespace1", "ext1"),
47+
new PatternDescription("Prefix", "Namespace1", "ext2"),
48+
new PatternDescription("Prefix", "Namespace2", "ext1"),
49+
new PatternDescription("Prefix", "Namespace2", "ext2")
50+
}
51+
},
52+
new object[]
53+
{
54+
new InputData(new[] {"Prefix1", "Prefix2"}, new[] {"Namespace1", "Namespace2"}, new[] {"ext1", "ext2"}),
55+
new[]
56+
{
57+
new PatternDescription("Prefix1", "Namespace1", "ext1"),
58+
new PatternDescription("Prefix1", "Namespace1", "ext2"),
59+
new PatternDescription("Prefix1", "Namespace2", "ext1"),
60+
new PatternDescription("Prefix1", "Namespace2", "ext2"),
61+
new PatternDescription("Prefix2", "Namespace1", "ext1"),
62+
new PatternDescription("Prefix2", "Namespace1", "ext2"),
63+
new PatternDescription("Prefix2", "Namespace2", "ext1"),
64+
new PatternDescription("Prefix2", "Namespace2", "ext2")
65+
}
66+
}
67+
};
68+
69+
public static IEnumerable<object[]> EmptyCollectionsData =>
70+
new List<object[]>
71+
{
72+
new object[]
73+
{
74+
new InputData(new string[] {}, new[] {"Namespace"}, new[] {"ext"}),
75+
new[] {new PatternDescription("*", "Namespace", "ext")}
76+
},
77+
new object[]
78+
{
79+
new InputData(null, new[] {"Namespace"}, new[] {"ext"}),
80+
new[] {new PatternDescription("*", "Namespace", "ext")}
81+
},
82+
new object[]
83+
{
84+
new InputData(new string[] {}, new string[] {}, new[] {"ext"}),
85+
new[] {new PatternDescription("*", "*", "ext")}
86+
},
87+
new object[]
88+
{
89+
new InputData(null, null, new[] {"ext"}),
90+
new[] {new PatternDescription("*", "*", "ext")}
91+
},
92+
new object[]
93+
{
94+
new InputData(new string[] {}, new string[] {}, new string[] {}),
95+
new[] {new PatternDescription("*", "*", "*")}
96+
},
97+
new object[]
98+
{
99+
new InputData(null, null, null),
100+
new[] {new PatternDescription("*", "*", "*")}
101+
}
102+
};
103+
104+
[Theory]
105+
[MemberData(nameof(NonEmptyCollectionsData))]
106+
[MemberData(nameof(EmptyCollectionsData))]
107+
public void Calculate_VariousInputsAreSupplied_ExpectedOutputsAreReturned(InputData input,
108+
PatternDescription[] expectedOutput)
109+
{
110+
var searcher = new PatternsCalculator();
111+
var paths = searcher.Calculate(input.Prefixes, input.Namespaces, input.Extensions).ToArray();
112+
113+
paths.Should().BeEquivalentTo(expectedOutput);
114+
}
115+
}
116+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="FluentAssertions" Version="5.6.0" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
12+
<PackageReference Include="xunit" Version="2.4.1" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
14+
<PrivateAssets>all</PrivateAssets>
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
16+
</PackageReference>
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\Solid.Core\Solid.Core.csproj" />
21+
</ItemGroup>
22+
23+
</Project>

Solid.Core/CollectionExtensions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Solid.Core
2+
{
3+
internal static class CollectionExtensions
4+
{
5+
internal static string[] Patch(this string[] input)
6+
{
7+
return input == null || input.Length == 0 ? new[] { Consts.WildCard } : input;
8+
}
9+
}
10+
}

Solid.Core/Consts.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Solid.Core
2+
{
3+
/// <summary>
4+
/// Constant values.
5+
/// </summary>
6+
public static class Consts
7+
{
8+
/// <summary>
9+
/// Wildcard value.
10+
/// </summary>
11+
public const string WildCard = "*";
12+
}
13+
}

Solid.Core/PatternDescription.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace Solid.Core
2+
{
3+
/// <summary>
4+
/// The file path pattern description.
5+
/// </summary>
6+
public struct PatternDescription
7+
{
8+
/// <summary>
9+
/// Initializes an instance of <see cref="PatternDescription"/>
10+
/// </summary>
11+
/// <param name="prefix">The prefix.</param>
12+
/// <param name="contents">The contents.</param>
13+
/// <param name="postfix">The postfix.</param>
14+
public PatternDescription(string prefix, string contents, string postfix)
15+
{
16+
Prefix = prefix;
17+
Contents = contents;
18+
Postfix = postfix;
19+
}
20+
21+
/// <summary>
22+
/// The prefix.
23+
/// </summary>
24+
public string Prefix { get; }
25+
26+
/// <summary>
27+
/// The contents.
28+
/// </summary>
29+
public string Contents { get; }
30+
31+
/// <summary>
32+
/// The postfix.
33+
/// </summary>
34+
public string Postfix { get; }
35+
}
36+
}

Solid.Core/PatternsCalculator.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Collections.Generic;
2+
3+
namespace Solid.Core
4+
{
5+
/// <summary>
6+
/// Calculates patterns for file paths.
7+
/// </summary>
8+
public class PatternsCalculator
9+
{
10+
/// <summary>
11+
/// Calculates patterns for file paths based on the required conditions.
12+
/// </summary>
13+
/// <param name="prefixes">The list of allowed prefixes. Leave empty if all are allowed.</param>
14+
/// <param name="namespaces">The list of allowed namespaces. Leave empty if all are allowed.</param>
15+
/// <param name="extensions">The list of allowed extensions. Leave empty if all are allowed.</param>
16+
/// <returns>The list of allowed patterns.</returns>
17+
public IEnumerable<PatternDescription> Calculate(string[] prefixes, string[] namespaces, string[] extensions)
18+
{
19+
prefixes = prefixes.Patch();
20+
namespaces = namespaces.Patch();
21+
extensions = extensions.Patch();
22+
23+
foreach (var prefix in prefixes)
24+
{
25+
foreach (var ns in namespaces)
26+
{
27+
foreach (var extension in extensions)
28+
{
29+
yield return new PatternDescription(prefix, ns, extension);
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)