Skip to content

Commit c019d8c

Browse files
committed
Improve SimpleProviderManaged debugging, point it at correct netcore project
1 parent 789cac7 commit c019d8c

File tree

5 files changed

+53
-40
lines changed

5 files changed

+53
-40
lines changed

ProjectedFSLib.Managed.Test/Helpers.cs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ namespace ProjectedFSLib.Managed.Test
1313
{
1414
class Helpers
1515
{
16-
private Process m_providerProcess;
17-
public Process ProviderProcess { get => m_providerProcess; set => m_providerProcess = value; }
16+
public Process ProviderProcess { get; set; }
1817

19-
private int m_waitTimeoutInMs;
20-
public int WaitTimeoutInMs { get => m_waitTimeoutInMs; set => m_waitTimeoutInMs = value; }
18+
public int WaitTimeoutInMs { get; set; }
2119

2220
internal enum NotifyWaitHandleNames
2321
{
@@ -34,26 +32,25 @@ internal enum NotifyWaitHandleNames
3432
FilePreConvertToFull,
3533
}
3634

37-
private List<EventWaitHandle> notificationEvents;
38-
public List<EventWaitHandle> NotificationEvents { get => notificationEvents; }
39-
35+
public List<EventWaitHandle> NotificationEvents { get; }
36+
4037
public Helpers(
4138
int waitTimeoutInMs
4239
)
4340
{
44-
m_waitTimeoutInMs = waitTimeoutInMs;
41+
WaitTimeoutInMs = waitTimeoutInMs;
4542

4643
// Create the events that the notifications tests use.
47-
notificationEvents = new List<EventWaitHandle>();
44+
NotificationEvents = new List<EventWaitHandle>();
4845
foreach (string eventName in Enum.GetNames(typeof(NotifyWaitHandleNames)))
4946
{
50-
notificationEvents.Add(new EventWaitHandle(false, EventResetMode.AutoReset, eventName));
47+
NotificationEvents.Add(new EventWaitHandle(false, EventResetMode.AutoReset, eventName));
5148
}
5249
}
5350

5451
public void StartTestProvider()
5552
{
56-
StartTestProvider(out string sourceRoot, out string virtRoot);
53+
StartTestProvider(out _, out _);
5754
}
5855

5956
public void StartTestProvider(out string sourceRoot, out string virtRoot)
@@ -64,7 +61,7 @@ public void StartTestProvider(out string sourceRoot, out string virtRoot)
6461
var providerExe = TestContext.Parameters.Get("ProviderExe");
6562

6663
// Create an event for the provider to signal once it is up and running.
67-
EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "ProviderTestProceed");
64+
var waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, "ProviderTestProceed");
6865

6966
// Set up the provider process and start it.
7067
ProviderProcess = new Process();
@@ -115,7 +112,7 @@ public void CreateRootsForTest(out string sourceName, out string virtRootName)
115112
{
116113
GetRootNamesForTest(out sourceName, out virtRootName);
117114

118-
DirectoryInfo sourceInfo = new DirectoryInfo(sourceName);
115+
var sourceInfo = new DirectoryInfo(sourceName);
119116
if (!sourceInfo.Exists)
120117
{
121118
sourceInfo.Create();
@@ -131,7 +128,7 @@ public string CreateVirtualFile(string fileName, string fileContent)
131128
GetRootNamesForTest(out string sourceRoot, out string virtRoot);
132129

133130
string sourceFileName = Path.Combine(sourceRoot, fileName);
134-
FileInfo sourceFile = new FileInfo(sourceFileName);
131+
var sourceFile = new FileInfo(sourceFileName);
135132

136133
if (!sourceFile.Exists)
137134
{
@@ -162,14 +159,14 @@ public string CreateVirtualFile(string fileName)
162159
// Returns the full path to the full file.
163160
public string CreateFullFile(string fileName, string fileContent)
164161
{
165-
GetRootNamesForTest(out string sourceRoot, out string virtRoot);
162+
GetRootNamesForTest(out _, out string virtRoot);
166163

167164
string fullFileName = Path.Combine(virtRoot, fileName);
168-
FileInfo fullFile = new FileInfo(fullFileName);
165+
var fullFile = new FileInfo(fullFileName);
169166

170167
if (!fullFile.Exists)
171168
{
172-
DirectoryInfo ancestorPath = new DirectoryInfo(Path.GetDirectoryName(fullFile.FullName));
169+
var ancestorPath = new DirectoryInfo(Path.GetDirectoryName(fullFile.FullName));
173170
if (!ancestorPath.Exists)
174171
{
175172
ancestorPath.Create();
@@ -193,10 +190,10 @@ public string CreateFullFile(string fileName)
193190

194191
public string ReadFileInVirtRoot(string fileName)
195192
{
196-
GetRootNamesForTest(out string sourceRoot, out string virtRoot);
193+
GetRootNamesForTest(out _, out string virtRoot);
197194

198195
string destFileName = Path.Combine(virtRoot, fileName);
199-
FileInfo destFile = new FileInfo(destFileName);
196+
var destFile = new FileInfo(destFileName);
200197
string fileContent;
201198
using (StreamReader sr = destFile.OpenText())
202199
{
@@ -208,7 +205,7 @@ public string ReadFileInVirtRoot(string fileName)
208205

209206
public FileStream OpenFileInVirtRoot(string fileName, FileMode mode)
210207
{
211-
GetRootNamesForTest(out string sourceRoot, out string virtRoot);
208+
GetRootNamesForTest(out _, out string virtRoot);
212209

213210
string destFileName = Path.Combine(virtRoot, fileName);
214211
FileStream stream = File.Open(destFileName, mode);

ProjectedFSLib.Managed.cs.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<PropertyGroup>
77
<OutputPath>$(BuildOutputDir)\$(MSBuildProjectName)\bin\$(Platform)\$(Configuration)\</OutputPath>
8-
<IntermediateOutputPath>$(BuildOutputDir)\$(MSBuildProjectName)\obj\$(Platform)\$(Configuration)\\</IntermediateOutputPath>
8+
<IntermediateOutputPath>$(BuildOutputDir)\$(MSBuildProjectName)\obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
99
<IntDir>$(BuildOutputDir)\$(MSBuildProjectName)\intermediate\$(Platform)\$(Configuration)\</IntDir>
1010
</PropertyGroup>
1111

scripts/BuildProjFS-Managed.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ IF NOT EXIST %nuget% (
1818
)
1919

2020
:: Acquire vswhere to find dev15/dev16 installations reliably.
21-
SET vswherever=2.5.2
21+
SET vswherever=2.8.4
2222
%nuget% install vswhere -Version %vswherever% || exit /b 1
2323
SET vswhere=%PROJFS_PACKAGESDIR%\vswhere.%vswherever%\tools\vswhere.exe
2424

simpleProviderManaged/Program.cs

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,47 @@
1-
// Copyright (c) Microsoft Corporation.
2-
// Licensed under the MIT license.
3-
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
44
using CommandLine;
55
using Serilog;
66
using System;
7+
using System.Threading;
78

89
namespace SimpleProviderManaged
910
{
1011
public class Program
1112
{
12-
public static void Main(string[] args)
13+
private enum ReturnCode
14+
{
15+
Success = 0,
16+
InvalidArguments = 1,
17+
GeneralException = 2,
18+
}
19+
20+
public static int Main(string[] args)
1321
{
14-
// We want verbose logging so we can see all our callback invocations.
15-
Log.Logger = new LoggerConfiguration()
16-
.WriteTo.Console()
17-
.WriteTo.File("SimpleProviderManaged-.log", rollingInterval: RollingInterval.Day)
18-
.CreateLogger();
22+
try
23+
{
24+
// We want verbose logging so we can see all our callback invocations.
25+
Log.Logger = new LoggerConfiguration()
26+
.WriteTo.Console()
27+
.WriteTo.File("SimpleProviderManaged-.log", rollingInterval: RollingInterval.Day)
28+
.CreateLogger();
1929

20-
Log.Information("Start");
30+
Log.Information("Start");
2131

22-
var parserResult = Parser.Default
23-
.ParseArguments<ProviderOptions>(args)
24-
.WithParsed((ProviderOptions options) => { Run(options); });
32+
var parserResult = Parser.Default
33+
.ParseArguments<ProviderOptions>(args)
34+
.WithParsed((ProviderOptions options) => Run(options));
2535

26-
Log.Information("Exit");
36+
Log.Information("Exit successfully");
37+
return (int) ReturnCode.Success;
38+
}
39+
catch (Exception ex)
40+
{
41+
Console.Error.WriteLine($"Unexpected exception: {ex}");
42+
Thread.Sleep(5 * 1000);
43+
return (int)ReturnCode.GeneralException;
44+
}
2745
}
2846

2947
private static void Run(ProviderOptions options)

simpleProviderManaged/SimpleProviderManaged.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
</ItemGroup>
1818

1919
<ItemGroup>
20-
<ProjectReference Include="..\ProjectedFSLib.Managed.API\NetFramework\ProjectedFSLib.Managed.vcxproj">
21-
<Project>{4e5f40b3-b56f-4b62-92cb-68e7e0e36afa}</Project>
22-
<Name>ProjectedFSLib.Managed</Name>
23-
</ProjectReference>
20+
<ProjectReference Condition="'$(TargetFramework)'=='net472'" Include="..\ProjectedFSLib.Managed.API\NetFramework\ProjectedFSLib.Managed.vcxproj" />
21+
<ProjectReference Condition="'$(TargetFramework)'=='netcoreapp3.1'" Include="..\ProjectedFSLib.Managed.API\NetCore\ProjectedFSLib.Managed.NetCore.vcxproj" />
2422
</ItemGroup>
2523

2624
<ItemGroup>

0 commit comments

Comments
 (0)