@@ -194,62 +194,6 @@ module internal YamlConversions =
194194 yaml.Load( reader)
195195 [| for doc in yaml.Documents -> yamlNodeToJsonValue doc.RootNode |]
196196
197- // Like yamlNodeToJsonValue, but for design-time type inference only.
198- // In YAML, quoted scalars are always strings by spec (the quoting is an explicit type annotation).
199- // When InferTypesFromValues=true, JsonInference would otherwise re-infer "01234" as int.
200- // We prevent this by substituting a guaranteed non-numeric sentinel for quoted scalars,
201- // so inference always returns string for them. Runtime parsing still uses yamlNodeToJsonValue.
202- let rec yamlNodeToJsonValueForInference ( node : YamlNode ) : JsonValue =
203- match node with
204- | :? YamlMappingNode as mapping ->
205- let props =
206- [| for kvp in mapping.Children do
207- let key =
208- match kvp.Key with
209- | :? YamlScalarNode as s -> s.Value
210- | other -> other.ToString()
211-
212- yield ( key, yamlNodeToJsonValueForInference kvp.Value) |]
213-
214- JsonValue.Record props
215-
216- | :? YamlSequenceNode as sequence ->
217- let elements =
218- [| for item in sequence.Children -> yamlNodeToJsonValueForInference item |]
219-
220- JsonValue.Array elements
221-
222- | :? YamlScalarNode as scalar ->
223- let value = scalar.Value
224-
225- if value = null then
226- JsonValue.Null
227- else
228- match scalar.Style with
229- | YamlDotNet.Core.ScalarStyle.SingleQuoted
230- | YamlDotNet.Core.ScalarStyle.DoubleQuoted
231- | YamlDotNet.Core.ScalarStyle.Literal
232- | YamlDotNet.Core.ScalarStyle.Folded ->
233- // Quoted scalar: YAML spec says this is always a string.
234- // Use a non-numeric sentinel so InferTypesFromValues does not re-infer
235- // the value content as int/bool/date/etc.
236- JsonValue.String " quoted-string"
237- | _ ->
238- // Plain scalars: same as runtime conversion
239- yamlNodeToJsonValue node
240-
241- | _ -> JsonValue.Null
242-
243- let parseYamlForInference ( text : string ) : JsonValue =
244- let yaml = YamlStream()
245- use reader = new StringReader( text)
246- yaml.Load( reader)
247-
248- if yaml.Documents.Count = 0 then
249- JsonValue.Null
250- else
251- yamlNodeToJsonValueForInference yaml.Documents.[ 0 ]. RootNode
252-
253197
254198// --------------------------------------------------------------------------------------
255199// YamlDocument - implements IJsonDocument so it can be used with JSON-based generated code
@@ -315,17 +259,6 @@ type YamlDocument =
315259 IsError = false ) >]
316260 static member ParseToJsonValueArray ( text : string ) : JsonValue [] = YamlConversions.parseYamlDocuments text
317261
318- /// <exclude />
319- /// Design-time only: like ParseToJsonValue but quoted scalars are represented with a
320- /// non-numeric sentinel string so that InferTypesFromValues does not re-infer them.
321- [<EditorBrowsableAttribute( EditorBrowsableState.Never) >]
322- [<CompilerMessageAttribute( " This method is intended for use in generated code only." ,
323- 10001 ,
324- IsHidden = true ,
325- IsError = false ) >]
326- static member ParseToJsonValueForInference ( text : string ) : JsonValue =
327- YamlConversions.parseYamlForInference text
328-
329262 /// <exclude />
330263 [<EditorBrowsableAttribute( EditorBrowsableState.Never) >]
331264 [<CompilerMessageAttribute( " This method is intended for use in generated code only." ,
0 commit comments