This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
tests/ServiceStack.Text.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,22 +97,17 @@ public static string ReferenceAssembyPath
9797 referenceAssembyPath = netFxReferenceBasePath + @"v4.0\" ;
9898 else
9999 {
100- var dir = new DirectoryInfo ( netFxReferenceBasePath ) ;
101- if ( dir . Exists )
100+ var v4Dirs = PclExport . Instance . GetDirectoryNames ( netFxReferenceBasePath , "v4*" ) ;
101+ if ( v4Dirs . Length > 0 )
102102 {
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'." ) ;
111110 }
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'." ) ;
116111 }
117112 }
118113#endif
Original file line number Diff line number Diff line change @@ -95,6 +95,26 @@ public override void CreateDirectory(string dirPath)
9595 Directory . CreateDirectory ( dirPath ) ;
9696 }
9797
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+
98118 public const string AppSettingsKey = "servicestack:license" ;
99119 public override void RegisterLicenseFromConfig ( )
100120 {
Original file line number Diff line number Diff line change @@ -164,6 +164,16 @@ public virtual string GetEnvironmentVariable(string name)
164164 return null ;
165165 }
166166
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+
167177 public virtual void WriteLine ( string line )
168178 {
169179 }
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 182182 <Compile Include =" JsonTests\JsonEnumTests.cs" />
183183 <Compile Include =" JsonTests\InvalidJsonTests.cs" />
184184 <Compile Include =" JsonTests\TypeInfoTests.cs" />
185+ <Compile Include =" PclApiTests.cs" />
185186 <Compile Include =" SerializationDelegatePerformanceTests.cs" />
186187 <Compile Include =" SerializationHookTests.cs" />
187188 <Compile Include =" StaticAccessorTests.cs" />
You can’t perform that action at this time.
0 commit comments