mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Replace custom method with File.ReadAllText() in ScriptAnalysis.cs (#26060)
This commit is contained in:
@@ -40,7 +40,7 @@ namespace System.Management.Automation
|
||||
// So eat the invalid operation
|
||||
}
|
||||
|
||||
string scriptContent = ReadScript(path);
|
||||
string scriptContent = File.ReadAllText(path, Encoding.Default);
|
||||
|
||||
ParseError[] errors;
|
||||
var moduleAst = (new Parser()).Parse(path, scriptContent, null, out errors, ParseMode.ModuleAnalysis);
|
||||
@@ -89,19 +89,6 @@ namespace System.Management.Automation
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static string ReadScript(string path)
|
||||
{
|
||||
using (FileStream readerStream = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
Microsoft.Win32.SafeHandles.SafeFileHandle safeFileHandle = readerStream.SafeFileHandle;
|
||||
|
||||
using (StreamReader scriptReader = new StreamReader(readerStream, Encoding.Default))
|
||||
{
|
||||
return scriptReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal List<string> DiscoveredExports { get; set; }
|
||||
|
||||
internal Dictionary<string, string> DiscoveredAliases { get; set; }
|
||||
|
||||
@@ -340,7 +340,7 @@ namespace System.Management.Automation
|
||||
|
||||
internal static Hashtable GetModuleManifestProperties(string psDataFilePath, string[] keys)
|
||||
{
|
||||
string dataFileContents = ScriptAnalysis.ReadScript(psDataFilePath);
|
||||
string dataFileContents = File.ReadAllText(psDataFilePath, Encoding.Default);
|
||||
ParseError[] parseErrors;
|
||||
var ast = (new Parser()).Parse(psDataFilePath, dataFileContents, null, out parseErrors, ParseMode.ModuleAnalysis);
|
||||
if (parseErrors.Length > 0)
|
||||
|
||||
Reference in New Issue
Block a user