From 8e18400682ce224b8860e7ec5a79e9e638a7a9a1 Mon Sep 17 00:00:00 2001 From: XperiAndri Date: Fri, 11 Dec 2020 02:27:56 +0200 Subject: [PATCH 1/2] Added Visual Studio default .gitignore --- .gitignore | 281 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 214 insertions(+), 67 deletions(-) diff --git a/.gitignore b/.gitignore index 2f9c6e28..4ce6fdde 100644 --- a/.gitignore +++ b/.gitignore @@ -1,37 +1,75 @@ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files +*.rsuser *.suo *.user +*.userosscache *.sln.docstates -# Xamarin Studio / monodevelop user-specific +# User-specific files (MonoDevelop/Xamarin Studio) *.userprefs # Build results -/src/Common/AssemblyInfo.fs [Dd]ebug/ +[Dd]ebugPublic/ [Rr]elease/ +[Rr]eleases/ x64/ -build/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ [Bb]in/ [Oo]bj/ +[Ll]og/ -# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets -!packages/*/build/ +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio *_i.c *_p.c +*_h.h *.ilk *.meta *.obj +*.iobj *.pch *.pdb +*.ipdb *.pgc *.pgd *.rsp @@ -41,26 +79,40 @@ build/ *.tlh *.tmp *.tmp_proj +*_wpftmp.csproj *.log *.vspscc *.vssscc .builds *.pidb -*.log +*.svclog *.scc +# Chutzpah Test files +_Chutzpah* + # Visual C++ cache files ipch/ *.aps *.ncb +*.opendb *.opensdf *.sdf *.cachefile +*.VC.db +*.VC.VC.opendb # Visual Studio profiler *.psess *.vsp *.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ # Guidance Automation Toolkit *.gpState @@ -68,6 +120,10 @@ ipch/ # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode # TeamCity is a build add-in _TeamCity* @@ -75,9 +131,25 @@ _TeamCity* # DotCover is a Code Coverage Tool *.dotCover +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + # NCrunch -*.ncrunch* +_NCrunch_* .*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ # Installshield output folder [Ee]xpress/ @@ -96,98 +168,173 @@ DocProject/Help/html publish/ # Publish Web Output -*.Publish.xml - -# Enable nuget.exe in the .nuget folder (though normally executables are not tracked) -!.nuget/NuGet.exe - -# Windows Azure Build Output -csx +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ *.build.csdef -# Windows Store app package directory +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ # Others -sql/ -*.Cache ClientBin/ -[Ss]tyle[Cc]op.* ~$* *~ *.dbmdl -*.[Pp]ublish.xml +*.dbproj.schemaview +*.jfm *.pfx *.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ # RIA/Silverlight projects Generated_Code/ -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak # SQL Server files -App_Data/*.mdf -App_Data/*.ldf +*.mdf +*.ldf +*.ndf +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- Backup*.rdl -#LightSwitch generated files -GeneratedArtifacts/ -_Pvt_Extensions/ -ModelManifest.xml +# Microsoft Fakes +FakesAssemblies/ -# ========================= -# Windows detritus -# ========================= +# GhostDoc plugin setting file +*.GhostDoc.xml -# Windows image file caches -Thumbs.db -ehthumbs.db +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ -# Folder config file -Desktop.ini +# Visual Studio 6 build log +*.plg -# Recycle Bin used on file shares -$RECYCLE.BIN/ +# Visual Studio 6 workspace options file +*.opt -# Mac desktop service store files -.DS_Store +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw -# =================================================== -# Exclude F# project specific directories and files -# =================================================== +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions -# NuGet Packages Directory -packages/ +# Paket dependency manager +.paket/paket.exe +paket-files/ -# Generated documentation folder -docs/output/ +# FAKE - F# Make +.fake/ -# Temp folder used for publishing docs -temp/ +# JetBrains Rider +.idea/ +*.sln.iml -# Test results produced by build -TestResults.xml +# CodeRush personal settings +.cr/personal -# Nuget outputs -nuget/*.nupkg -release.cmd -release.sh -localpackages/ -*.orig -docs/content/license.md -docs/content/release-notes.md -.fake/ -.idea/ -.vs/ -.ionide/ -*.svclog -TestResult.xml +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc -# Paket dependency manager -.paket/ -paket-files/ +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb \ No newline at end of file From fc2c584c25d8a762ca74e00a02121f20ff7d5564 Mon Sep 17 00:00:00 2001 From: XperiAndri Date: Sat, 12 Dec 2020 15:43:09 +0200 Subject: [PATCH 2/2] Fixed relative path resolution, added support for FTP scheme --- SwaggerProvider.sln | 1 + .../Provider.OpenApiClient.fs | 12 +++++---- .../Provider.SwaggerClient.fs | 11 +++++--- src/SwaggerProvider.DesignTime/Utils.fs | 27 +++++++++++++------ 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/SwaggerProvider.sln b/SwaggerProvider.sln index 17d51142..7ef06f64 100644 --- a/SwaggerProvider.sln +++ b/SwaggerProvider.sln @@ -18,6 +18,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{302BCCA4-51B8-475C-9131-548CDC824026}" ProjectSection(SolutionItems) = preProject build.fsx = build.fsx + global.json = global.json README.md = README.md docs\RELEASE_NOTES.md = docs\RELEASE_NOTES.md EndProjectSection diff --git a/src/SwaggerProvider.DesignTime/Provider.OpenApiClient.fs b/src/SwaggerProvider.DesignTime/Provider.OpenApiClient.fs index 7c20e20f..97347c18 100644 --- a/src/SwaggerProvider.DesignTime/Provider.OpenApiClient.fs +++ b/src/SwaggerProvider.DesignTime/Provider.OpenApiClient.fs @@ -2,10 +2,10 @@ namespace SwaggerProvider open System open System.Reflection -open System.Net.Http open ProviderImplementation.ProvidedTypes open Microsoft.FSharp.Core.CompilerServices open Swagger +open SwaggerProvider.Internal open SwaggerProvider.Internal.v3.Compilers module Cache = @@ -41,21 +41,23 @@ type public OpenApiClientTypeProvider(cfg : TypeProviderConfig) as this = t.DefineStaticParameters( staticParams, fun typeName args -> - let schemaPathRaw = unbox args.[0] + let schemaPath = + let schemaPathRaw = unbox args.[0] + SchemaReader.getAbsolutePath cfg.ResolutionFolder schemaPathRaw let ignoreOperationId = unbox args.[1] let ignoreControllerPrefix = unbox args.[2] let preferNullable = unbox args.[3] let preferAsync = unbox args.[4] let cacheKey = - (schemaPathRaw, ignoreOperationId, ignoreControllerPrefix, preferNullable, preferAsync) + (schemaPath, ignoreOperationId, ignoreControllerPrefix, preferNullable, preferAsync) |> sprintf "%A" let addCache() = lazy let schemaData = - SwaggerProvider.Internal.SchemaReader.readSchemaPath "" schemaPathRaw + SchemaReader.readSchemaPath "" schemaPath |> Async.RunSynchronously let openApiReader = Microsoft.OpenApi.Readers.OpenApiStringReader() @@ -73,7 +75,7 @@ type public OpenApiClientTypeProvider(cfg : TypeProviderConfig) as this = let tempAsm = ProvidedAssembly() let ty = ProvidedTypeDefinition(tempAsm, ns, typeName, Some typeof, isErased = false, hideObjectMethods = true) - ty.AddXmlDoc ("OpenAPI Provider for " + schemaPathRaw) + ty.AddXmlDoc ("OpenAPI Provider for " + schemaPath) ty.AddMembers tys tempAsm.AddTypes [ty] diff --git a/src/SwaggerProvider.DesignTime/Provider.SwaggerClient.fs b/src/SwaggerProvider.DesignTime/Provider.SwaggerClient.fs index 4bd662a2..962867fc 100644 --- a/src/SwaggerProvider.DesignTime/Provider.SwaggerClient.fs +++ b/src/SwaggerProvider.DesignTime/Provider.SwaggerClient.fs @@ -5,6 +5,7 @@ open System.Reflection open ProviderImplementation.ProvidedTypes open Microsoft.FSharp.Core.CompilerServices open Swagger +open SwaggerProvider.Internal open SwaggerProvider.Internal.v2.Parser open SwaggerProvider.Internal.v2.Compilers @@ -55,7 +56,9 @@ type public SwaggerTypeProvider(cfg : TypeProviderConfig) as this = t.DefineStaticParameters( staticParams, fun typeName args -> - let schemaPathRaw = unbox args.[0] + let schemaPath = + let schemaPathRaw = unbox args.[0] + SchemaReader.getAbsolutePath cfg.ResolutionFolder schemaPathRaw let headersStr = unbox args.[1] let ignoreOperationId = unbox args.[2] let ignoreControllerPrefix = unbox args.[3] @@ -63,13 +66,13 @@ type public SwaggerTypeProvider(cfg : TypeProviderConfig) as this = let preferAsync = unbox args.[5] let cacheKey = - (schemaPathRaw, headersStr, ignoreOperationId, ignoreControllerPrefix, preferNullable, preferAsync) + (schemaPath, headersStr, ignoreOperationId, ignoreControllerPrefix, preferNullable, preferAsync) |> sprintf "%A" let addCache() = lazy let schemaData = - SwaggerProvider.Internal.SchemaReader.readSchemaPath headersStr schemaPathRaw + SchemaReader.readSchemaPath headersStr schemaPath |> Async.RunSynchronously let schema = SwaggerParser.parseSchema schemaData @@ -80,7 +83,7 @@ type public SwaggerTypeProvider(cfg : TypeProviderConfig) as this = let tempAsm = ProvidedAssembly() let ty = ProvidedTypeDefinition(tempAsm, ns, typeName, Some typeof, isErased = false, hideObjectMethods = true) - ty.AddXmlDoc ("Swagger Provider for " + schemaPathRaw) + ty.AddXmlDoc ("Swagger Provider for " + schemaPath) ty.AddMembers tys tempAsm.AddTypes [ty] diff --git a/src/SwaggerProvider.DesignTime/Utils.fs b/src/SwaggerProvider.DesignTime/Utils.fs index 5b46613f..052621ad 100644 --- a/src/SwaggerProvider.DesignTime/Utils.fs +++ b/src/SwaggerProvider.DesignTime/Utils.fs @@ -2,12 +2,21 @@ namespace SwaggerProvider.Internal module SchemaReader = open System + open System.IO + open System.Net open System.Net.Http + let getAbsolutePath (resolutionFolder:string) (schemaPathRaw:string) = + let uri = Uri(schemaPathRaw, UriKind.RelativeOrAbsolute) + if uri.IsAbsoluteUri then schemaPathRaw + elif Path.IsPathRooted schemaPathRaw + then Path.Combine(Path.GetPathRoot(resolutionFolder), schemaPathRaw.Substring(1)) + else Path.Combine(resolutionFolder, schemaPathRaw) + let readSchemaPath (headersStr:string) (schemaPathRaw:string) = async { - match schemaPathRaw.StartsWith("http", true, null) with - | true -> + match Uri(schemaPathRaw).Scheme with + | "https" | "http" -> let headers = headersStr.Split('|') |> Seq.choose (fun x -> @@ -25,20 +34,22 @@ module SchemaReader = let! res = async { let! response = client.SendAsync(request) |> Async.AwaitTask - return! response.Content.ReadAsStringAsync() |> Async.AwaitTask + return! response.Content.ReadAsStringAsync() |> Async.AwaitTask } |> Async.Catch match res with | Choice1Of2 x -> return x - | Choice2Of2 (:? System.Net.WebException as wex) when wex.Response <> null -> + | Choice2Of2 (:? System.Net.WebException as wex) when not <| isNull wex.Response -> use stream = wex.Response.GetResponseStream() - use reader = new System.IO.StreamReader(stream) + use reader = new StreamReader(stream) let err = reader.ReadToEnd() - return + return if String.IsNullOrEmpty err then raise wex else err.ToString() | Choice2Of2 e -> return failwith(e.ToString()) - | false -> - use sr = new System.IO.StreamReader(schemaPathRaw) + | _ -> + let request = WebRequest.Create(schemaPathRaw) + use! response = request.GetResponseAsync() |> Async.AwaitTask + use sr = new StreamReader(response.GetResponseStream()) return! sr.ReadToEndAsync() |> Async.AwaitTask }