Skip to content

Commit

Permalink
Check for success - hopefully fixes #653
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamTheCoder committed Oct 11, 2020
1 parent fba7ee8 commit c49f071
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 1 addition & 3 deletions CodeConverter/ConversionResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ConversionResult
{
private string _sourcePathOrNull;
private string _targetPathOrNull;
public bool Success { get; private set; }
public bool Success => ConvertedCode != null;
public string ConvertedCode { get; private set; }
public IReadOnlyList<string> Exceptions { get; internal set; }
internal bool IsIdentity { get; set; }
Expand All @@ -28,13 +28,11 @@ public string TargetPathOrNull {

public ConversionResult(string convertedCode = null)
{
Success = convertedCode != null;
ConvertedCode = convertedCode;
}

public ConversionResult(params Exception[] exceptions)
{
Success = exceptions.Length == 0;
Exceptions = exceptions.Select(e => e.ToString()).ToList();
}

Expand Down
14 changes: 8 additions & 6 deletions Vsix/CodeConversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,17 @@ private async Task WriteConvertedFilesAndShowSummaryAsync(IAsyncEnumerable<Conve
if (!string.IsNullOrWhiteSpace(exceptionsAsString)) {
errors.Add(exceptionsAsString);
}

if (convertedFile.Success) {
files.Add(convertedFile.TargetPathOrNull);

files.Add(convertedFile.TargetPathOrNull);
if (convertedFile.ConvertedCode.Length > longestFileLength) {
longestFileLength = convertedFile.ConvertedCode.Length;
longestFilePath = convertedFile.TargetPathOrNull;
}

if (convertedFile.ConvertedCode.Length > longestFileLength) {
longestFileLength = convertedFile.ConvertedCode.Length;
longestFilePath = convertedFile.TargetPathOrNull;
convertedFile.WriteToFile();
}

convertedFile.WriteToFile();
}

await FinalizeConversionAsync(files, errors, longestFilePath, filesToOverwrite);
Expand Down

0 comments on commit c49f071

Please sign in to comment.