@@ -50,9 +50,8 @@ public string TempPath
5050 private set
5151 {
5252 tempPath
53- = ( string . IsNullOrEmpty ( value )
54- || string . IsNullOrWhiteSpace ( value ) )
55- ? Environment . GetEnvironmentVariable ( "TEMP" )
53+ = string . IsNullOrWhiteSpace ( value )
54+ ? Path . GetTempPath ( )
5655 : value ;
5756 }
5857
@@ -69,10 +68,9 @@ public string LocalAppDataPath
6968 }
7069 private set
7170 {
72- localAppdataPath
73- = ( string . IsNullOrEmpty ( value )
74- || string . IsNullOrWhiteSpace ( value ) )
75- ? Environment . GetEnvironmentVariable ( "LOCALAPPDATA" )
71+ localAppdataPath
72+ = string . IsNullOrWhiteSpace ( value )
73+ ? Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData )
7674 : value ;
7775 }
7876 }
@@ -90,8 +88,7 @@ public string ModuleRepository
9088 set
9189 {
9290 moduleRepository
93- = ( string . IsNullOrEmpty ( value )
94- || string . IsNullOrWhiteSpace ( value ) )
91+ = string . IsNullOrWhiteSpace ( value )
9592 ? "PSGallery"
9693 : value ;
9794 }
@@ -106,14 +103,6 @@ public string PSSAAppDataPath
106103 {
107104 return pssaAppDataPath ;
108105 }
109- private set
110- {
111- var leaf
112- = ( string . IsNullOrEmpty ( value ) || string . IsNullOrWhiteSpace ( value ) )
113- ? "PSScriptAnalyzer"
114- : value ;
115- pssaAppDataPath = Path . Combine ( LocalAppDataPath , leaf ) ;
116- }
117106 }
118107
119108 /// <summary>
@@ -156,8 +145,7 @@ private void SetupPSSAAppData()
156145 tempModulePath = GetTempModulePath ( symLinkPath ) ;
157146
158147 // check if the temp dir exists
159- if ( tempModulePath != null
160- && Directory . Exists ( tempModulePath ) )
148+ if ( Directory . Exists ( tempModulePath ) )
161149 {
162150 return ;
163151 }
@@ -204,12 +192,12 @@ private string GetPSSATempDirPath()
204192 // Return the first line of the file
205193 private string GetTempModulePath ( string symLinkPath )
206194 {
207- var symLinkLines = File . ReadAllLines ( symLinkPath ) ;
208- if ( symLinkLines . Length != 1 )
195+ string line ;
196+ using ( var fileStream = new StreamReader ( symLinkPath ) )
209197 {
210- return null ;
198+ line = fileStream . ReadLine ( ) ;
211199 }
212- return symLinkLines [ 0 ] ;
200+ return line ;
213201 }
214202
215203 private void SaveModule ( PSObject module )
@@ -278,9 +266,13 @@ public ModuleDependencyHandler(
278266 // and then passed into modulehandler
279267 TempPath = tempPath ;
280268 LocalAppDataPath = localAppDataPath ;
281- PSSAAppDataPath = pssaAppDataPath ;
282269 ModuleRepository = moduleRepository ;
283-
270+ pssaAppDataPath = Path . Combine (
271+ LocalAppDataPath ,
272+ string . IsNullOrWhiteSpace ( pssaAppDataPath )
273+ ? "PSScriptAnalyzer"
274+ : pssaAppDataPath ) ;
275+
284276 modulesFound = new Dictionary < string , PSObject > ( ) ;
285277
286278 // TODO Add PSSA Version in the path
0 commit comments