A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

31 lines
856 B

using System;
using System.IO;
namespace XamlNameReferenceGenerator.Infrastructure
{
internal class PhysicalFileDebugger
{
private const string DefaultPath = @"C:\Users\prizr\Documents\GitHub\XamlNameReferenceGenerator\debug.txt";
private readonly string _path;
public PhysicalFileDebugger(string path = DefaultPath) => _path = path;
public string Debug(Func<string> function)
{
if (File.Exists(_path))
File.Delete(_path);
try
{
var sourceCode = function();
File.WriteAllText(_path, sourceCode);
return sourceCode;
}
catch (Exception exception)
{
File.WriteAllText(_path, exception.ToString());
throw;
}
}
}
}