Skip to content

Commit

Permalink
Use Document.Name for filepath
Browse files Browse the repository at this point in the history
  • Loading branch information
zahalzel committed Aug 16, 2022
1 parent e49d12b commit 7cde59d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -45,7 +44,6 @@ public ProjectModifier(ProvisioningToolOptions toolOptions, IEnumerable<string>
/// <returns></returns>
public async Task AddAuthCodeAsync()
{
Debugger.Launch();
if (string.IsNullOrEmpty(_toolOptions.ProjectFilePath))
{
var csProjFiles = _files.Where(file => file.EndsWith(".csproj"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
Expand All @@ -9,7 +8,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using Microsoft.DotNet.MSIdentity.Shared;
using Microsoft.DotNet.Scaffolding.Shared.CodeModifier;
using Microsoft.DotNet.Scaffolding.Shared.CodeModifier.CodeChange;

Expand Down Expand Up @@ -497,12 +495,8 @@ internal static async Task<Document> ModifyDocumentText(Document fileDoc, IEnume

internal static async Task<string> UpdateDocument(Document document)
{
Debugger.Launch();
var classFileTxt = await document.GetTextAsync();

// Note: For files without .cs extension, document.Name is the full filepath
var filePath = document.Name.EndsWith(".cs") ? document.FilePath : document.Name;
File.WriteAllText(filePath, classFileTxt.ToString(), new UTF8Encoding(false));
File.WriteAllText(document.Name, classFileTxt.ToString(), new UTF8Encoding(false));

return $"Modified {document.Name}.\n"; // todo strings.
}
Expand Down

0 comments on commit 7cde59d

Please sign in to comment.