This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +57
-14
lines changed
tests/ServiceStack.Text.Tests Expand file tree Collapse file tree 5 files changed +57
-14
lines changed Original file line number Diff line number Diff line change @@ -97,22 +97,17 @@ public static string ReferenceAssembyPath
97
97
referenceAssembyPath = netFxReferenceBasePath + @"v4.0\" ;
98
98
else
99
99
{
100
- var dir = new DirectoryInfo ( netFxReferenceBasePath ) ;
101
- if ( dir . Exists )
100
+ var v4Dirs = PclExport . Instance . GetDirectoryNames ( netFxReferenceBasePath , "v4*" ) ;
101
+ if ( v4Dirs . Length > 0 )
102
102
{
103
- var fxDirs = dir . GetDirectories ( ) ;
104
- foreach ( var fxDir in fxDirs )
105
- {
106
- if ( fxDir . Name . StartsWith ( "v4" ) )
107
- {
108
- return referenceAssembyPath = netFxReferenceBasePath + fxDir . Name + @"\" ;
109
- }
110
- }
103
+ referenceAssembyPath = v4Dirs [ v4Dirs . Length - 1 ] ; //latest v4
104
+ }
105
+ else
106
+ {
107
+ throw new FileNotFoundException (
108
+ "Could not infer .NET Reference Assemblies path, e.g '{0}'.\n " . Fmt ( netFxReferenceBasePath + @"v4.0\" ) +
109
+ "Provide path manually 'Env.ReferenceAssembyPath'." ) ;
111
110
}
112
-
113
- throw new FileNotFoundException (
114
- "Could not infer .NET Reference Assemblies path, e.g '{0}'.\n " . Fmt ( netFxReferenceBasePath + @"v4.0\" ) +
115
- "Provide path manually 'Env.ReferenceAssembyPath'." ) ;
116
111
}
117
112
}
118
113
#endif
Original file line number Diff line number Diff line change @@ -95,6 +95,26 @@ public override void CreateDirectory(string dirPath)
95
95
Directory . CreateDirectory ( dirPath ) ;
96
96
}
97
97
98
+ public override string [ ] GetFileNames ( string dirPath , string searchPattern = null )
99
+ {
100
+ if ( ! Directory . Exists ( dirPath ) )
101
+ return new string [ 0 ] ;
102
+
103
+ return searchPattern != null
104
+ ? Directory . GetFiles ( dirPath , searchPattern )
105
+ : Directory . GetFiles ( dirPath ) ;
106
+ }
107
+
108
+ public override string [ ] GetDirectoryNames ( string dirPath , string searchPattern = null )
109
+ {
110
+ if ( ! Directory . Exists ( dirPath ) )
111
+ return new string [ 0 ] ;
112
+
113
+ return searchPattern != null
114
+ ? Directory . GetDirectories ( dirPath , searchPattern )
115
+ : Directory . GetDirectories ( dirPath ) ;
116
+ }
117
+
98
118
public const string AppSettingsKey = "servicestack:license" ;
99
119
public override void RegisterLicenseFromConfig ( )
100
120
{
Original file line number Diff line number Diff line change @@ -164,6 +164,16 @@ public virtual string GetEnvironmentVariable(string name)
164
164
return null ;
165
165
}
166
166
167
+ public virtual string [ ] GetFileNames ( string dirPath , string searchPattern = null )
168
+ {
169
+ return new string [ 0 ] ;
170
+ }
171
+
172
+ public virtual string [ ] GetDirectoryNames ( string dirPath , string searchPattern = null )
173
+ {
174
+ return new string [ 0 ] ;
175
+ }
176
+
167
177
public virtual void WriteLine ( string line )
168
178
{
169
179
}
Original file line number Diff line number Diff line change
1
+ using NUnit . Framework ;
2
+
3
+ namespace ServiceStack . Text . Tests
4
+ {
5
+ [ TestFixture ]
6
+ public class PclApiTests
7
+ {
8
+ [ Test , Explicit ]
9
+ public void Can_scan_reference_assemblies ( )
10
+ {
11
+ var refDir = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\" ;
12
+
13
+ PclExport . Instance . GetDirectoryNames ( refDir ) . PrintDump ( ) ;
14
+ PclExport . Instance . GetDirectoryNames ( refDir , "v4*" ) . PrintDump ( ) ;
15
+ }
16
+ }
17
+ }
Original file line number Diff line number Diff line change 182
182
<Compile Include =" JsonTests\JsonEnumTests.cs" />
183
183
<Compile Include =" JsonTests\InvalidJsonTests.cs" />
184
184
<Compile Include =" JsonTests\TypeInfoTests.cs" />
185
+ <Compile Include =" PclApiTests.cs" />
185
186
<Compile Include =" SerializationDelegatePerformanceTests.cs" />
186
187
<Compile Include =" SerializationHookTests.cs" />
187
188
<Compile Include =" StaticAccessorTests.cs" />
You can’t perform that action at this time.
0 commit comments