You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let asms = (if toTgt then getTargetAssemblies() else getSourceAssemblies())
9121
9120
let fullName = fixName t.FullName
9122
9121
9123
-
// TODO: this linear search through all available source/target assemblies feels as if it must be too slow in some cases.
9124
-
// However, we store type translations in various tables (typeTableFwd and typeTableBwd) so perhaps it is not a problem
9125
-
let rec loop i =
9126
-
if i < 0 then
9127
-
let msg =
9128
-
if toTgt then sprintf "The design-time type '%O' utilized by a type provider was not found in the target reference assembly set '%A'. You may be referencing a profile which contains fewer types than those needed by the type provider you are using." t (getTargetAssemblies() |> Seq.toList)
9129
-
elif getSourceAssemblies() |> Seq.isEmpty then sprintf "A failure occured while determining compilation references"
9130
-
else sprintf "The target type '%O' utilized by a type provider was not found in the design-time assembly set '%A'. Please report this problem to the project site for the type provider." t (getSourceAssemblies() |> Seq.toList)
9131
-
failwith msg
9132
-
else
9133
-
match tryGetTypeFromAssembly toTgt t.Assembly.FullName fullName asms.[i] with
9134
-
| Some (newT, canSave) ->
9135
-
if canSave then table.[t] <- newT
9136
-
newT
9137
-
| None -> loop (i - 1)
9138
-
loop (asms.Count - 1)
9122
+
let bestGuess =
9123
+
asms |> Seq.tryFind(fun a -> a.FullName = t.Assembly.FullName)
9124
+
|> Option.bind(fun a -> tryGetTypeFromAssembly toTgt t.Assembly.FullName fullName a)
9125
+
9126
+
match bestGuess with
9127
+
| Some (newT, canSave) ->
9128
+
if canSave then table.[t] <- newT
9129
+
newT
9130
+
| None ->
9131
+
9132
+
// TODO: this linear search through all available source/target assemblies feels as if it must be too slow in some cases.
9133
+
// However, we store type translations in various tables (typeTableFwd and typeTableBwd) so perhaps it is not a problem
9134
+
let rec loop i =
9135
+
if i < 0 then
9136
+
let msg =
9137
+
if toTgt then sprintf "The design-time type '%O' utilized by a type provider was not found in the target reference assembly set '%A'. You may be referencing a profile which contains fewer types than those needed by the type provider you are using." t (getTargetAssemblies() |> Seq.toList)
9138
+
elif getSourceAssemblies() |> Seq.isEmpty then sprintf "A failure occured while determining compilation references"
9139
+
else sprintf "The target type '%O' utilized by a type provider was not found in the design-time assembly set '%A'. Please report this problem to the project site for the type provider." t (getSourceAssemblies() |> Seq.toList)
9140
+
failwith msg
9141
+
else
9142
+
match tryGetTypeFromAssembly toTgt t.Assembly.FullName fullName asms.[i] with
9143
+
| Some (newT, canSave) ->
9144
+
if canSave then table.[t] <- newT
9145
+
newT
9146
+
| None -> loop (i - 1)
9147
+
loop (asms.Count - 1)
9139
9148
9140
9149
and convType toTgt (t:Type) =
9141
9150
let table = (if toTgt then typeTableFwd else typeTableBwd)
9142
9151
match table.TryGetValue(t) with
9143
9152
| true, newT -> newT
9144
9153
| false, _ ->
9145
-
if t :? ProvidedTypeSymbol && (t :?> ProvidedTypeSymbol).IsFSharpTypeAbbreviation then t
9154
+
let isSymbol = t :? ProvidedTypeSymbol
9155
+
if isSymbol && (t :?> ProvidedTypeSymbol).IsFSharpTypeAbbreviation then t
9146
9156
// Types annotated with units-of-measure
9147
-
elif t :? ProvidedTypeSymbol && (t :?> ProvidedTypeSymbol).IsFSharpUnitAnnotated then
9157
+
elif isSymbol && (t :?> ProvidedTypeSymbol).IsFSharpUnitAnnotated then
9148
9158
let genericType = t.GetGenericTypeDefinition()
9149
9159
let newT = convTypeRef toTgt genericType
9150
9160
let typeArguments = t.GetGenericArguments() |> Array.map (convType toTgt) |> Array.toList
0 commit comments