Skip to content

Commit 17053ba

Browse files
committed
Fix When_Depends_Updon_File_In_Nested_Folder_Should_Not_Reference_It_By_FullName
1 parent 3b49a8a commit 17053ba

File tree

5 files changed

+249
-6
lines changed

5 files changed

+249
-6
lines changed

Generaid.Tests/Generaid.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
<Content Include="HierarchyBuilderFacts.Generate_Should_Delete_Old_Files_InThe_Folder.approved.txt" />
119119
<Content Include="HierarchyBuilderFacts.Generate_Should_Delete_Old_Files_InThe_Nested_Folder.approved.txt" />
120120
<Content Include="HierarchyBuilderFacts.Generate_Should_Respect_Subfolders.approved.txt" />
121+
<Content Include="HierarchyBuilderFacts.When_Depends_Updon_File_In_Nested_Folder_Should_Not_Reference_It_By_FullName.approved.txt" />
121122
</ItemGroup>
122123
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
123124
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props')" />
4+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
5+
<PropertyGroup>
6+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8+
<ProjectGuid>{0FCE68B2-59F3-4D7D-9836-BF848ECCB36A}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>Sample</RootNamespace>
12+
<AssemblyName>Sample.Tests</AssemblyName>
13+
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<NuGetPackageImportStamp>09650d69</NuGetPackageImportStamp>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="ApprovalTests, Version=3.0.0.0, Culture=neutral, PublicKeyToken=11bd7d124fc62e0f, processorArchitecture=MSIL">
36+
<HintPath>..\packages\ApprovalTests.3.0.11\lib\net40\ApprovalTests.dll</HintPath>
37+
<Private>True</Private>
38+
</Reference>
39+
<Reference Include="ApprovalUtilities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=11bd7d124fc62e0f, processorArchitecture=MSIL">
40+
<HintPath>..\packages\ApprovalUtilities.3.0.11\lib\net45\ApprovalUtilities.dll</HintPath>
41+
<Private>True</Private>
42+
</Reference>
43+
<Reference Include="ApprovalUtilities.Net45, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
44+
<HintPath>..\packages\ApprovalUtilities.3.0.11\lib\net45\ApprovalUtilities.Net45.dll</HintPath>
45+
<Private>True</Private>
46+
</Reference>
47+
<Reference Include="Autofac, Version=3.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
48+
<HintPath>..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath>
49+
<Private>True</Private>
50+
</Reference>
51+
<Reference Include="EntityFramework.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
52+
<HintPath>..\packages\EntityFramework.Core.7.0.0-rc1-final\lib\net451\EntityFramework.Core.dll</HintPath>
53+
<Private>True</Private>
54+
</Reference>
55+
<Reference Include="EntityFramework.MicrosoftSqlServer, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
56+
<HintPath>..\packages\EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final\lib\net451\EntityFramework.MicrosoftSqlServer.dll</HintPath>
57+
<Private>True</Private>
58+
</Reference>
59+
<Reference Include="EntityFramework.Relational, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
60+
<HintPath>..\packages\EntityFramework.Relational.7.0.0-rc1-final\lib\net451\EntityFramework.Relational.dll</HintPath>
61+
<Private>True</Private>
62+
</Reference>
63+
<Reference Include="FluentAssertions, Version=4.3.2.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
64+
<HintPath>..\packages\FluentAssertions.4.3.2\lib\net45\FluentAssertions.dll</HintPath>
65+
<Private>True</Private>
66+
</Reference>
67+
<Reference Include="FluentAssertions.Core, Version=4.3.2.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
68+
<HintPath>..\packages\FluentAssertions.4.3.2\lib\net45\FluentAssertions.Core.dll</HintPath>
69+
<Private>True</Private>
70+
</Reference>
71+
<Reference Include="Microsoft.Extensions.Caching.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
72+
<HintPath>..\packages\Microsoft.Extensions.Caching.Abstractions.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Caching.Abstractions.dll</HintPath>
73+
<Private>True</Private>
74+
</Reference>
75+
<Reference Include="Microsoft.Extensions.Caching.Memory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
76+
<HintPath>..\packages\Microsoft.Extensions.Caching.Memory.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Caching.Memory.dll</HintPath>
77+
<Private>True</Private>
78+
</Reference>
79+
<Reference Include="Microsoft.Extensions.Configuration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
80+
<HintPath>..\packages\Microsoft.Extensions.Configuration.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Configuration.dll</HintPath>
81+
<Private>True</Private>
82+
</Reference>
83+
<Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
84+
<HintPath>..\packages\Microsoft.Extensions.Configuration.Abstractions.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
85+
<Private>True</Private>
86+
</Reference>
87+
<Reference Include="Microsoft.Extensions.Configuration.Binder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
88+
<HintPath>..\packages\Microsoft.Extensions.Configuration.Binder.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Configuration.Binder.dll</HintPath>
89+
<Private>True</Private>
90+
</Reference>
91+
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
92+
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.DependencyInjection.dll</HintPath>
93+
<Private>True</Private>
94+
</Reference>
95+
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
96+
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
97+
<Private>True</Private>
98+
</Reference>
99+
<Reference Include="Microsoft.Extensions.Logging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
100+
<HintPath>..\packages\Microsoft.Extensions.Logging.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Logging.dll</HintPath>
101+
<Private>True</Private>
102+
</Reference>
103+
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
104+
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
105+
<Private>True</Private>
106+
</Reference>
107+
<Reference Include="Microsoft.Extensions.OptionsModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
108+
<HintPath>..\packages\Microsoft.Extensions.OptionsModel.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.OptionsModel.dll</HintPath>
109+
<Private>True</Private>
110+
</Reference>
111+
<Reference Include="Microsoft.Extensions.Primitives, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
112+
<HintPath>..\packages\Microsoft.Extensions.Primitives.1.0.0-rc1-final\lib\net451\Microsoft.Extensions.Primitives.dll</HintPath>
113+
<Private>True</Private>
114+
</Reference>
115+
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
116+
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
117+
<Private>True</Private>
118+
</Reference>
119+
<Reference Include="Remotion.Linq, Version=2.0.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
120+
<HintPath>..\packages\Remotion.Linq.2.0.1\lib\net45\Remotion.Linq.dll</HintPath>
121+
<Private>True</Private>
122+
</Reference>
123+
<Reference Include="System" />
124+
<Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
125+
<HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
126+
<Private>True</Private>
127+
</Reference>
128+
<Reference Include="System.ComponentModel.DataAnnotations" />
129+
<Reference Include="System.Core" />
130+
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
131+
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.4.0.0-beta-23516\lib\portable-net45+win8+wp8+wpa81\System.Diagnostics.DiagnosticSource.dll</HintPath>
132+
<Private>True</Private>
133+
</Reference>
134+
<Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
135+
<HintPath>..\packages\Ix-Async.1.2.5\lib\net45\System.Interactive.Async.dll</HintPath>
136+
<Private>True</Private>
137+
</Reference>
138+
<Reference Include="System.Transactions" />
139+
<Reference Include="System.Xml.Linq" />
140+
<Reference Include="System.Data.DataSetExtensions" />
141+
<Reference Include="Microsoft.CSharp" />
142+
<Reference Include="System.Data" />
143+
<Reference Include="System.Xml" />
144+
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
145+
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
146+
<Private>True</Private>
147+
</Reference>
148+
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
149+
<HintPath>..\packages\xunit.assert.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.assert.dll</HintPath>
150+
<Private>True</Private>
151+
</Reference>
152+
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
153+
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\portable-net45+win8+wp8+wpa81\xunit.core.dll</HintPath>
154+
<Private>True</Private>
155+
</Reference>
156+
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
157+
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
158+
<Private>True</Private>
159+
</Reference>
160+
</ItemGroup>
161+
<ItemGroup>
162+
<Compile Include="ChangeSetFacts.cs" />
163+
<Compile Include="CsProjExtensions.cs" />
164+
<Compile Include="GeneratedBlah\Foo.cs" />
165+
<Compile Include="HierarchyFacts.cs" />
166+
<Compile Include="Properties\AssemblyInfo.cs" />
167+
<Compile Include="XDocFacts.cs" />
168+
<Compile Include="Generated\root" />
169+
<Compile Include="Generated\companies\Microsoft" />
170+
<Compile Include="Generated\companies\John">
171+
<DependentUpon>Microsoft</DependentUpon>
172+
</Compile>
173+
<Compile Include="Generated\companies\Marry">
174+
<DependentUpon>Microsoft</DependentUpon>
175+
</Compile>
176+
<Compile Include="Generated\companies\Apple" />
177+
<Compile Include="Generated\companies\Alice">
178+
<DependentUpon>Apple</DependentUpon>
179+
</Compile>
180+
<Compile Include="Generated\companies\Bob">
181+
<DependentUpon>Apple</DependentUpon>
182+
</Compile>
183+
</ItemGroup>
184+
<ItemGroup>
185+
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
186+
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
187+
</ItemGroup>
188+
<ItemGroup>
189+
<ProjectReference Include="..\Generator\Generator.csproj">
190+
<Project>{7B227385-B83D-4E16-868E-E307967D0EE4}</Project>
191+
<Name>Generator</Name>
192+
</ProjectReference>
193+
<ProjectReference Include="..\Sample\Sample.csproj">
194+
<Project>{D3B9E4FF-68D0-4898-A85E-281950135DFB}</Project>
195+
<Name>Sample</Name>
196+
</ProjectReference>
197+
</ItemGroup>
198+
<ItemGroup>
199+
<None Include="packages.config" />
200+
</ItemGroup>
201+
<ItemGroup>
202+
<Content Include="HierarchyFacts.Build.approved.txt">
203+
<DependentUpon>HierarchyFacts.cs</DependentUpon>
204+
</Content>
205+
<Content Include="HierarchyFacts.Expand2.approved.txt">
206+
<DependentUpon>HierarchyFacts.cs</DependentUpon>
207+
</Content>
208+
<Compile Include="Gene\rated\should-be-cleanud.up" />
209+
</ItemGroup>
210+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
211+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
212+
<PropertyGroup>
213+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
214+
</PropertyGroup>
215+
<Error Condition="!Exists('..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.1.0\build\portable-net45+win8+wp8+wpa81\xunit.core.props'))" />
216+
</Target>
217+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
218+
Other similar extension points exist, see Microsoft.Common.targets.
219+
<Target Name="BeforeBuild">
220+
</Target>
221+
<Target Name="AfterBuild">
222+
</Target>
223+
-->
224+
</Project>

Generaid.Tests/HierarchyBuilderFacts.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,21 @@ public void Generate_Should_Respect_Subfolders()
152152
ReadAllText(@"c:\proj\sample.proj"));
153153
}
154154
[Fact]
155+
public void When_Depends_Updon_File_In_Nested_Folder_Should_Not_Reference_It_By_FullName()
156+
{
157+
foreach (var company in _model.Companies)
158+
{
159+
company.NeedSubfolder = true;
160+
foreach (var employee in company.Employees)
161+
employee.NeedSubfolder = true;
162+
}
163+
164+
_hierarchyBuilder.Generate();
165+
166+
Approvals.Verify(_fs.File.
167+
ReadAllText(@"c:\proj\sample.proj"));
168+
}
169+
[Fact]
155170
public void DoNotGenerate_Should_Work()
156171
{
157172
_model.Companies[0].DoNotGenerate = true;

Generaid.Tests/Model.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ public class EmployeeGenerator : ITransformer
2424
{
2525
public EmployeeGenerator(Employee employee) { _employee = employee; }
2626
private readonly Employee _employee;
27-
public string Name => _employee.Name;
27+
public string Name =>
28+
(_employee.NeedSubfolder ? @"companies\" : "")
29+
+ _employee.Name;
30+
//public string Name => _employee.Name;
2831
public string TransformText() => _employee.Name;
2932
}
3033
public sealed class Employee
3134
{
3235
public string Name { get; }
36+
public bool NeedSubfolder { get; set; }
3337

3438
public Employee(string name)
3539
{

Generaid/Internal/CsProjExtensions.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,15 @@ private static void Insert(this XContainer doc, string preferredFolder, params C
4747
.Attribute("Include")?.Value
4848
.StartsWith(preferredFolder)==true))
4949
.FirstOrDefault()?
50-
.Add(genNodes
51-
.Select(Selector
52-
));
50+
.Add(genNodes.Select(CreateCompileElement));
5351
}
5452

55-
private static XElement Selector(CmpNode n)
53+
private static XElement CreateCompileElement(CmpNode n)
5654
{
5755
var xElement = new XElement(Ns + "Compile", new XAttribute("Include", n.FullName));
5856
if (n.DependentUpon != "")
59-
xElement.Add(new XElement(Ns + "DependentUpon", n.DependentUpon));
57+
xElement.Add(new XElement(Ns + "DependentUpon",
58+
Path.GetFileName(n.DependentUpon)));
6059
return xElement;
6160
}
6261

0 commit comments

Comments
 (0)