Skip to content

Commit d109be0

Browse files
authored
feat: include TP config information in cache key (#283)
1 parent ed3414f commit d109be0

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

src/SwaggerProvider.DesignTime/Provider.OpenApiClient.fs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,19 @@ type public OpenApiClientTypeProvider(cfg: TypeProviderConfig) as this =
5959
let preferAsync = unbox<bool> args.[4]
6060
let ssrfProtection = unbox<bool> args.[5]
6161

62+
// Cache key includes cfg.RuntimeAssembly, cfg.ResolutionFolder, and cfg.SystemRuntimeAssemblyVersion
63+
// to differentiate between different TFM builds (same approach as FSharp.Data)
64+
// See: https://github.com/fsprojects/FSharp.Data/blob/main/src/FSharp.Data.DesignTime/CommonProviderImplementation/Helpers.fs
6265
let cacheKey =
63-
(schemaPathRaw, ignoreOperationId, ignoreControllerPrefix, preferNullable, preferAsync, ssrfProtection)
66+
(schemaPathRaw,
67+
ignoreOperationId,
68+
ignoreControllerPrefix,
69+
preferNullable,
70+
preferAsync,
71+
ssrfProtection,
72+
cfg.RuntimeAssembly,
73+
cfg.ResolutionFolder,
74+
cfg.SystemRuntimeAssemblyVersion)
6475
|> sprintf "%A"
6576

6677
let addCache() =

src/SwaggerProvider.DesignTime/Provider.SwaggerClient.fs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,20 @@ type public SwaggerTypeProvider(cfg: TypeProviderConfig) as this =
6262
let preferAsync = unbox<bool> args.[5]
6363
let ssrfProtection = unbox<bool> args.[6]
6464

65+
// Cache key includes cfg.RuntimeAssembly, cfg.ResolutionFolder, and cfg.SystemRuntimeAssemblyVersion
66+
// to differentiate between different TFM builds (same approach as FSharp.Data)
67+
// See: https://github.com/fsprojects/FSharp.Data/blob/main/src/FSharp.Data.DesignTime/CommonProviderImplementation/Helpers.fs
6568
let cacheKey =
66-
(schemaPathRaw, headersStr, ignoreOperationId, ignoreControllerPrefix, preferNullable, preferAsync, ssrfProtection)
69+
(schemaPathRaw,
70+
headersStr,
71+
ignoreOperationId,
72+
ignoreControllerPrefix,
73+
preferNullable,
74+
preferAsync,
75+
ssrfProtection,
76+
cfg.RuntimeAssembly,
77+
cfg.ResolutionFolder,
78+
cfg.SystemRuntimeAssemblyVersion)
6779
|> sprintf "%A"
6880

6981
let addCache() =

0 commit comments

Comments
 (0)