Skip to content

Commit

Permalink
Fixed assembly resolve for YamlDotNet
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-tihon committed Dec 22, 2015
1 parent faedaf8 commit d1980e4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 0.3.0 - December 22 2015
* Added support of schemes in YAML format

#### 0.2.0 - December 13 2015
* `AssemblyResolve` handler that resolve location of 3rd party dependencies
* Added dependencies on `Newtonsoft.Json` NuGet package
Expand Down
2 changes: 1 addition & 1 deletion docs/content/index.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Documentation
<div class="span6">
<div class="well well-small" id="nuget">
The SwaggerProvider library can be <a href="https://nuget.org/packages/SwaggerProvider">installed from NuGet</a>:
<pre>PM> Install-Package SwaggerProvider -Pre</pre>
<pre>PM> Install-Package SwaggerProvider</pre>
</div>
</div>
<div class="span1"></div>
Expand Down
6 changes: 3 additions & 3 deletions src/Common/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("SwaggerProvider")>]
[<assembly: AssemblyProductAttribute("SwaggerProvider")>]
[<assembly: AssemblyDescriptionAttribute("F# Type Provider for Swagger")>]
[<assembly: AssemblyVersionAttribute("0.2.0")>]
[<assembly: AssemblyFileVersionAttribute("0.2.0")>]
[<assembly: AssemblyVersionAttribute("0.3.0")>]
[<assembly: AssemblyFileVersionAttribute("0.3.0")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "0.2.0"
let [<Literal>] Version = "0.3.0"
17 changes: 12 additions & 5 deletions src/SwaggerProvider.DesignTime/Configuration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@ let getSwaggerProviderRuntimeAssembly() =
/// Finds directories relative to 'dirs' using the specified 'patterns'.
/// Patterns is a string, such as "..\foo\*\bar" split by '\'. Standard
/// .NET libraries do not support "*", so we have to do it ourselves..
let rec searchDirectories patterns dirs =
let rec searchDirectories (patterns:string list) dirs =
match patterns with
| [] -> dirs
| "*"::patterns ->
dirs |> List.collect (Directory.GetDirectories >> List.ofSeq)
| name::patterns when name.EndsWith("*") ->
let prefix = name.TrimEnd([|'*'|])
dirs
|> List.collect (fun dir ->
Directory.GetDirectories dir
|> Array.filter (fun x -> x.IndexOf(prefix, dir.Length) >= 0)
|> List.ofArray
)
|> searchDirectories patterns
| name::patterns ->
dirs |> List.map (fun d -> Path.Combine(d, name))
dirs
|> List.map (fun d -> Path.Combine(d, name))
|> searchDirectories patterns

/// Returns the real assembly location - when shadow copying is enabled, this
Expand All @@ -46,8 +53,8 @@ let getProbingLocations() =
Logging.logf <| sprintf "Root %s" root
let config = System.Configuration.ConfigurationManager.OpenExeConfiguration(root)
let pattern = config.AppSettings.Settings.["ProbingLocations"]
Logging.logf <| sprintf "Pattern %s" pattern.Value
if pattern <> null then
Logging.logf <| sprintf "Pattern %s" pattern.Value
[ yield root
let pattern = pattern.Value.Split(';', ',') |> List.ofSeq
for pat in pattern do
Expand Down
9 changes: 7 additions & 2 deletions src/SwaggerProvider.Runtime/YamlParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ let Parse : (string -> Node) =

let deserializer = new Deserializer();
fun (text:string) ->
use reader = new StringReader(text)
deserializer.Deserialize(reader) |> loop
try
use reader = new StringReader(text)
deserializer.Deserialize(reader) |> loop
with
| :? YamlDotNet.Core.YamlException as e when e.InnerException <> null ->
raise e.InnerException // inner exceptions are much more informative
| _ -> reraise()
2 changes: 1 addition & 1 deletion src/SwaggerProvider/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="ProbingLocations" value="../../../*/lib/net40" />
<add key="ProbingLocations" value="../../../Newtonsoft.Json*/lib/net40;../../../YamlDotNet*/lib/net35" />
</appSettings>
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" /></runtime></configuration>

0 comments on commit d1980e4

Please sign in to comment.