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
Adding or adjusting errors emitted by the compiler is usually straightforward (though it can sometimes imply deeper compiler work). Here's the general process:
11
+
*`ErrorLogger`
12
+
*`FSharpDiagnosticSeverity`
13
+
*`FSharpDiagnostic`
14
+
15
+
and functions
16
+
17
+
*`warning` - emit a warning
18
+
*`errorR` - emit an error and continue
19
+
*`error` - emit an error and throw an exception
20
+
*`errorRecovery` - recover from an exception
21
+
22
+
## Diagnostic messages
23
+
24
+
For the compiler, a key file is `FSComp.txt` olding most of the messages. There are also a few other similar files including some old error messages in `FSStrings.resx`.
25
+
26
+
## Adding Diagnostics
27
+
28
+
Adding or adjusting diagnostics emitted by the compiler is usually straightforward (though it can sometimes imply deeper compiler work). Here's the general process:
11
29
12
30
1. Reproduce the compiler error or warning with the latest F# compiler built from the [F# compiler repository](https://github.com/dotnet/fsharp).
13
31
2. Find the error code (such as `FS0020`) in the message.
@@ -19,23 +37,23 @@ From here, you can either simply update the error test, or you can use some of t
19
37
20
38
If you're including data from user code in an error message, it's important to also write a test that verifies the exact error message for a given string of F# code.
21
39
22
-
## Formatting User Text from Typed Tree items
40
+
## Formatting Typed Tree items in Diagnostics
23
41
24
-
When formatting Typed Tree objects such as `TyconRef`s as text, you normally use either
42
+
Diagnostics must often format TAST items as user text. When formatting these, you normally use either
25
43
26
44
* The functions in the `NicePrint` module such as `NicePrint.outputTyconRef`. These take a `DisplayEnv` that records the context in which a type was referenced, for example, the open namespaces. Opened namespaces are not shown in the displayed output.
27
45
28
46
* The `DisplayName` properties on the relevant object. This drops the `'n` text that .NET adds to the compiled name of a type, and uses the F#-facing name for a type rather than the compiled name for a type (for example, the name given in a `CompiledName` attribute).
29
47
30
-
* The functions such as `Tastops.fullTextOfTyconRef`, used to show the full, qualified name of an item.
31
-
32
48
When formatting "info" objects, see the functions in the `NicePrint` module.
33
49
34
50
## Notes on displaying types
35
51
36
-
When displaying a type, you will normally want to "prettify" the type first. This converts any remaining type inference variables to new, better user-friendly type variables with names like `'a`. Various functions prettify types prior to display, for example, `NicePrint.layoutPrettifiedTypes` and others.
52
+
Diagnostics must often format types.
53
+
54
+
* When displaying a type, you will normally want to "prettify" the type first. This converts any remaining type inference variables to new, better user-friendly type variables with names like `'a`. Various functions prettify types prior to display, for example, `NicePrint.layoutPrettifiedTypes` and others.
37
55
38
-
When displaying multiple types in a comparative way, for example, two types that didn't match, you will want to display the minimal amount of infomation to convey the fact that the two types are different, for example, `NicePrint.minimalStringsOfTwoTypes`.
56
+
*When displaying multiple types in a comparative way, for example, two types that didn't match, you will want to display the minimal amount of infomation to convey the fact that the two types are different, for example, `NicePrint.minimalStringsOfTwoTypes`.
39
57
40
-
When displaying a type, you have the option of displaying the constraints implied by any type variables mentioned in the types, appended as `when ...`. For example, `NicePrint.layoutPrettifiedTypeAndConstraints`.
58
+
*When displaying a type, you have the option of displaying the constraints implied by any type variables mentioned in the types, appended as `when ...`. For example, `NicePrint.layoutPrettifiedTypeAndConstraints`.
Copy file name to clipboardExpand all lines: docs/fcs/index.md
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
---
2
2
title: Overview
3
-
category: Compiler Service
4
-
categoryindex: 2
5
-
index: 1
3
+
category: Compiler Service API
4
+
categoryindex: 300
5
+
index: 100
6
6
---
7
7
# FSharp.Compiler.Service
8
8
@@ -48,7 +48,15 @@ The libraries contain additional public API that can be used, but is not documen
48
48
49
49
> **NOTE:** The FSharp.Compiler.Service API is subject to change when later versions of the nuget package are published
50
50
51
-
## API Namespaces
51
+
## The Public Surface Area
52
+
53
+
We are in the process of cleaning up the surface area of FCS to allow it to be fully binary compatible going forward.
54
+
55
+
The full current surface area can be seen at: https://fsharp.github.io/fsharp-compiler-docs/reference/index.html
56
+
57
+
The API is generally designed with F#/.NET design conventions (e.g. types in namespaces, not modules, no nesting of modules etc.) and we must continue to iterate to make this so.
58
+
59
+
The parts of the compiler under `FSharp.Compiler.AbstractIL.*` are "incidental" and not really designed for public use apart from the hook for JetBrains Rider (Aside: In theory all these other parts could be renamed to FSharp.Compiler though there's no need to do that right now). These internal parts tend to be implemented with the "module containing lots of stuff in one big file" approach for layers of the compiler.
0 commit comments