@@ -249,77 +249,97 @@ let private CheckCompilerFeatureRequiredAttribute (g: TcGlobals) cattrs msg m =
249
249
| _ ->
250
250
ErrorD ( ObsoleteDiagnostic( true , " " , msg, " " , m))
251
251
252
- let private CheckILObsoleteAttributes ( g : TcGlobals ) isByrefLikeTyconRef cattrs m =
252
+ let private extractILObsoleteAttributeInfo namedArgs =
253
253
let extractILAttribValueFrom name namedArgs =
254
254
match namedArgs with
255
255
| ExtractILAttributeNamedArg name ( AttribElemStringArg v) -> v
256
256
| _ -> " "
257
- let ( AttribInfo ( tref , _ )) = g.attrib_ SystemObsolete
258
- match TryDecodeILAttribute tref cattrs with
259
- | Some ([ ILAttribElem.String ( Some msg) ], namedArgs) when not isByrefLikeTyconRef ->
260
- let diagnosticId = extractILAttribValueFrom " DiagnosticId" namedArgs
261
- let urlFormat = extractILAttribValueFrom " UrlFormat" namedArgs
262
- WarnD( ObsoleteDiagnostic( false , diagnosticId, msg, urlFormat, m))
263
- | Some ([ ILAttribElem.String ( Some msg); ILAttribElem.Bool isError ], namedArgs) when not isByrefLikeTyconRef ->
264
- let diagnosticId = extractILAttribValueFrom " DiagnosticId" namedArgs
265
- let urlFormat = extractILAttribValueFrom " UrlFormat" namedArgs
266
- if isError then
267
- if g.langVersion.SupportsFeature( LanguageFeature.RequiredPropertiesSupport) then
268
- CheckCompilerFeatureRequiredAttribute g cattrs msg m
269
- else
270
- ErrorD ( ObsoleteDiagnostic( true , diagnosticId, msg, urlFormat, m))
271
- else
272
- WarnD ( ObsoleteDiagnostic( false , diagnosticId, msg, urlFormat, m))
257
+ let diagnosticId = extractILAttribValueFrom " DiagnosticId" namedArgs
258
+ let urlFormat = extractILAttribValueFrom " UrlFormat" namedArgs
259
+ ( diagnosticId, urlFormat)
273
260
274
- | Some ([ ILAttribElem.String None ], namedArgs) when not isByrefLikeTyconRef ->
275
- let diagnosticId = extractILAttribValueFrom " DiagnosticId" namedArgs
276
- let urlFormat = extractILAttribValueFrom " UrlFormat" namedArgs
277
- WarnD( ObsoleteDiagnostic( false , diagnosticId, " " , urlFormat, m))
278
- | Some (_, namedArgs) when not isByrefLikeTyconRef ->
279
- let diagnosticId = extractILAttribValueFrom " DiagnosticId" namedArgs
280
- let urlFormat = extractILAttribValueFrom " UrlFormat" namedArgs
281
- WarnD( ObsoleteDiagnostic( false , diagnosticId, " " , urlFormat, m))
282
- | _ ->
261
+ let private CheckILObsoleteAttributes ( g : TcGlobals ) isByrefLikeTyconRef cattrs m =
262
+ if isByrefLikeTyconRef then
283
263
CompleteD
264
+ else
265
+ let ( AttribInfo ( tref , _ )) = g.attrib_ SystemObsolete
266
+ match TryDecodeILAttribute tref cattrs with
267
+ // [<Obsolete>]
268
+ // [<Obsolete("Message")>]
269
+ // [<Obsolete("Message", true)>]
270
+ // [<Obsolete("Message", DiagnosticId = "DiagnosticId")>]
271
+ // [<Obsolete("Message", DiagnosticId = "DiagnosticId", UrlFormat = "UrlFormat")>]
272
+ // [<Obsolete(DiagnosticId = "DiagnosticId")>]
273
+ // [<Obsolete(DiagnosticId = "DiagnosticId", UrlFormat = "UrlFormat")>]
274
+ // [<Obsolete("Message", true, DiagnosticId = "DiagnosticId")>]
275
+ // [<Obsolete("Message", true, DiagnosticId = "DiagnosticId", UrlFormat = "UrlFormat")>]
276
+ // Constructors deciding on IsError and Message properties.
277
+ | Some ([ attribElement ], namedArgs) ->
278
+ let diagnosticId , urlFormat = extractILObsoleteAttributeInfo namedArgs
279
+ let msg =
280
+ match attribElement with
281
+ | ILAttribElem.String ( Some msg) -> msg
282
+ | ILAttribElem.String None
283
+ | _ -> " "
284
+
285
+ WarnD ( ObsoleteDiagnostic( false , diagnosticId, msg, urlFormat, m))
286
+ | Some ([ ILAttribElem.String ( Some msg); ILAttribElem.Bool isError ], namedArgs) ->
287
+ let diagnosticId , urlFormat = extractILObsoleteAttributeInfo namedArgs
288
+ if isError then
289
+ if g.langVersion.SupportsFeature( LanguageFeature.RequiredPropertiesSupport) then
290
+ CheckCompilerFeatureRequiredAttribute g cattrs msg m
291
+ else
292
+ ErrorD ( ObsoleteDiagnostic( true , diagnosticId, msg, urlFormat, m))
293
+ else
294
+ WarnD ( ObsoleteDiagnostic( false , diagnosticId, msg, urlFormat, m))
295
+
296
+ // No message, no error, no diagnostic id, no url format
297
+ | Some _ -> WarnD( ObsoleteDiagnostic( false , " " , " " , " " , m))
298
+ | None -> CompleteD
284
299
285
300
/// Check IL attributes for 'ObsoleteAttribute', returning errors and warnings as data
286
301
let private CheckILAttributes ( g : TcGlobals ) isByrefLikeTyconRef cattrs m =
287
302
trackErrors {
288
303
do ! CheckILObsoleteAttributes g isByrefLikeTyconRef cattrs m
289
304
}
305
+
290
306
let langVersionPrefix = " --langversion:preview"
291
307
292
- let private CheckObsoleteAttributes g attribs m =
293
- let extractAttribValueFrom name namedArgs =
308
+ let private extractObsoleteAttributeInfo namedArgs =
309
+ let extractILAttribValueFrom name namedArgs =
294
310
match namedArgs with
295
311
| ExtractAttribNamedArg name ( AttribStringArg v) -> v
296
312
| _ -> " "
313
+ let diagnosticId = extractILAttribValueFrom " DiagnosticId" namedArgs
314
+ let urlFormat = extractILAttribValueFrom " UrlFormat" namedArgs
315
+ ( diagnosticId, urlFormat)
297
316
317
+ let private CheckObsoleteAttributes g attribs m =
298
318
trackErrors {
299
319
match TryFindFSharpAttribute g g.attrib_ SystemObsolete attribs with
320
+ // [<Obsolete>]
321
+ // [<Obsolete("Message")>]
322
+ // [<Obsolete("Message", true)>]
323
+ // [<Obsolete("Message", DiagnosticId = "DiagnosticId")>]
324
+ // [<Obsolete("Message", DiagnosticId = "DiagnosticId", UrlFormat = "UrlFormat")>]
325
+ // [<Obsolete(DiagnosticId = "DiagnosticId")>]
326
+ // [<Obsolete(DiagnosticId = "DiagnosticId", UrlFormat = "UrlFormat")>]
327
+ // [<Obsolete("Message", true, DiagnosticId = "DiagnosticId")>]
328
+ // [<Obsolete("Message", true, DiagnosticId = "DiagnosticId", UrlFormat = "UrlFormat")>]
329
+ // Constructors deciding on IsError and Message properties.
300
330
| Some( Attrib( unnamedArgs= [ AttribStringArg s ]; propVal= namedArgs)) ->
301
- let diagnosticId = extractAttribValueFrom " DiagnosticId" namedArgs
302
- let urlFormat = extractAttribValueFrom " UrlFormat" namedArgs
331
+ let diagnosticId , urlFormat = extractObsoleteAttributeInfo namedArgs
303
332
do ! WarnD( ObsoleteDiagnostic( false , diagnosticId, s, urlFormat, m))
304
-
305
333
| Some( Attrib( unnamedArgs= [ AttribStringArg s; AttribBoolArg( isError) ]; propVal= namedArgs)) ->
306
- let diagnosticId = extractAttribValueFrom " DiagnosticId" namedArgs
307
- let urlFormat = extractAttribValueFrom " UrlFormat" namedArgs
334
+ let diagnosticId , urlFormat = extractObsoleteAttributeInfo namedArgs
308
335
if isError then
309
336
do ! ErrorD ( ObsoleteDiagnostic( true , diagnosticId, s, urlFormat, m))
310
337
else
311
338
do ! WarnD ( ObsoleteDiagnostic( false , diagnosticId, s, urlFormat, m))
312
- | Some( Attrib( unnamedArgs= [ AttribStringArg s ]; propVal= namedArgs)) ->
313
- let diagnosticId = extractAttribValueFrom " DiagnosticId" namedArgs
314
- let urlFormat = extractAttribValueFrom " UrlFormat" namedArgs
315
-
316
- do ! WarnD( ObsoleteDiagnostic( false , diagnosticId, s, urlFormat, m))
317
339
| Some( Attrib( propVal= namedArgs)) ->
318
- let diagnosticId = extractAttribValueFrom " DiagnosticId" namedArgs
319
- let urlFormat = extractAttribValueFrom " UrlFormat" namedArgs
340
+ let diagnosticId , urlFormat = extractObsoleteAttributeInfo namedArgs
320
341
do ! WarnD( ObsoleteDiagnostic( false , diagnosticId, " " , urlFormat, m))
321
- | None ->
322
- ()
342
+ | None -> ()
323
343
}
324
344
325
345
let private CheckCompilerMessageAttribute g attribs m =
0 commit comments