Skip to content

Commit

Permalink
Merge main to release/dev17.4 (#13492)
Browse files Browse the repository at this point in the history
* ValRepInfoForDisplay added for improved quick info for functions defined in expressions

* Update

* Update QuickInfoTests.fs

* Update QuickInfoTests.fs

* Update

* add identifier analysis script (#13486)

* add identifier analysis script

* add identifier analysis script

* Update fantomas alpha 11 (#13481)

Co-authored-by: Don Syme <[email protected]>
Co-authored-by: Peter Semkin <[email protected]>
Co-authored-by: Don Syme <[email protected]>
Co-authored-by: Florian Verdonck <[email protected]>
Co-authored-by: Petr Semkin <[email protected]>
  • Loading branch information
6 people authored Jul 12, 2022
1 parent 795248a commit 65643c1
Show file tree
Hide file tree
Showing 77 changed files with 1,147 additions and 570 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"fantomas": {
"version": "5.0.0-alpha-008",
"version": "5.0.0-alpha-011",
"commands": [
"fantomas"
]
Expand Down
62 changes: 39 additions & 23 deletions src/Compiler/AbstractIL/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ open Internal.Utilities

let logging = false

let _ = if logging then dprintn "* warning: Il.logging is on"
let _ =
if logging then
dprintn "* warning: Il.logging is on"

let int_order = LanguagePrimitives.FastGenericComparer<int>

Expand Down Expand Up @@ -68,11 +70,13 @@ let memoizeNamespaceRightTable =
let memoizeNamespacePartTable = ConcurrentDictionary<string, string>()

let splitNameAt (nm: string) idx =
if idx < 0 then failwith "splitNameAt: idx < 0"
if idx < 0 then
failwith "splitNameAt: idx < 0"

let last = nm.Length - 1

if idx > last then failwith "splitNameAt: idx > last"
if idx > last then
failwith "splitNameAt: idx > last"

(nm.Substring(0, idx)), (if idx < last then nm.Substring(idx + 1, last - idx) else "")

Expand Down Expand Up @@ -551,7 +555,8 @@ type ILAssemblyRef(data) =
addC (convDigit (int32 v / 16))
addC (convDigit (int32 v % 16))
// retargetable can be true only for system assemblies that definitely have Version
if aref.Retargetable then add ", Retargetable=Yes"
if aref.Retargetable then
add ", Retargetable=Yes"

b.ToString()

Expand Down Expand Up @@ -2497,8 +2502,10 @@ let typeKindOfFlags nm (super: ILType option) flags =

if name = "System.Enum" then
ILTypeDefKind.Enum
elif (name = "System.Delegate" && nm <> "System.MulticastDelegate")
|| name = "System.MulticastDelegate" then
elif
(name = "System.Delegate" && nm <> "System.MulticastDelegate")
|| name = "System.MulticastDelegate"
then
ILTypeDefKind.Delegate
elif name = "System.ValueType" && nm <> "System.Enum" then
ILTypeDefKind.ValueType
Expand Down Expand Up @@ -3925,7 +3932,8 @@ let cdef_cctorCode2CodeOrCreate tag imports f (cd: ILTypeDef) =
[|
yield f cctor
for md in mdefs do
if md.Name <> ".cctor" then yield md
if md.Name <> ".cctor" then
yield md
|])

cd.With(methods = methods)
Expand Down Expand Up @@ -4888,7 +4896,8 @@ type ILTypeSigParser(tstring: string) =

// Does the type name start with a leading '['? If so, ignore it
// (if the specialization type is in another module, it will be wrapped in bracket)
if here () = '[' then drop ()
if here () = '[' then
drop ()

// 1. Iterate over beginning of type, grabbing the type name and determining if it's generic or an array
let typeName =
Expand Down Expand Up @@ -4947,8 +4956,11 @@ type ILTypeSigParser(tstring: string) =
let scope =
if (here () = ',' || here () = ' ') && (peek () <> '[' && peekN 2 <> '[') then
let grabScopeComponent () =
if here () = ',' then drop () // ditch the ','
if here () = ' ' then drop () // ditch the ' '
if here () = ',' then
drop () // ditch the ','

if here () = ' ' then
drop () // ditch the ' '

while (peek () <> ',' && peek () <> ']' && peek () <> nil) do
step ()
Expand All @@ -4969,8 +4981,11 @@ type ILTypeSigParser(tstring: string) =
ILScopeRef.Local

// strip any extraneous trailing brackets or commas
if (here () = ']') then drop ()
if (here () = ',') then drop ()
if (here () = ']') then
drop ()

if (here () = ',') then
drop ()

// build the IL type
let tref = mkILTyRef (scope, typeName)
Expand Down Expand Up @@ -5549,17 +5564,18 @@ let resolveILMethodRefWithRescope r (td: ILTypeDef) (mref: ILMethodRef) =
let argTypes = mref.ArgTypes |> List.map r
let retType: ILType = r mref.ReturnType

match possibles
|> List.filter (fun md ->
mref.CallingConv = md.CallingConv
&&
// REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct
(md.Parameters, argTypes)
||> List.lengthsEqAndForall2 (fun p1 p2 -> r p1.Type = p2)
&&
// REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct
r md.Return.Type = retType)
with
match
possibles
|> List.filter (fun md ->
mref.CallingConv = md.CallingConv
&&
// REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct
(md.Parameters, argTypes)
||> List.lengthsEqAndForall2 (fun p1 p2 -> r p1.Type = p2)
&&
// REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct
r md.Return.Type = retType)
with
| [] ->
failwith (
"no method named "
Expand Down
12 changes: 8 additions & 4 deletions src/Compiler/AbstractIL/ilnativeres.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ type CvtResFile() =
reader.Read(pAdditional.data, 0, pAdditional.data.Length) |> ignore<int>
stream.Position <- stream.Position + 3L &&& ~~~ 3L

if pAdditional.pstringType.theString = Unchecked.defaultof<_>
&& (pAdditional.pstringType.Ordinal = uint16 CvtResFile.RT_DLGINCLUDE) then
if
pAdditional.pstringType.theString = Unchecked.defaultof<_>
&& (pAdditional.pstringType.Ordinal = uint16 CvtResFile.RT_DLGINCLUDE)
then
() (* ERROR ContinueNotSupported *)
else
resourceNames.Add pAdditional
Expand Down Expand Up @@ -454,7 +456,8 @@ type VersionHelper() =
doBreak <- false
() (* ERROR ContinueNotSupported *)
(* ERROR BreakNotSupported *)
if not breakLoop then i <- i + 1
if not breakLoop then
i <- i + 1

if hasWildcard then
let mutable (i: int) = lastExplicitValue
Expand Down Expand Up @@ -1149,7 +1152,8 @@ type NativeResourceWriter() =
if id >= 0 then
writer.WriteInt32 id
else
if name = Unchecked.defaultof<_> then name <- String.Empty
if name = Unchecked.defaultof<_> then
name <- String.Empty

writer.WriteUInt32(nameOffset ||| 0x80000000u)
dataWriter.WriteUInt16(uint16 name.Length)
Expand Down
60 changes: 40 additions & 20 deletions src/Compiler/AbstractIL/ilprint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -661,16 +661,20 @@ let goutput_fdef _tref env os (fd: ILFieldDef) =
output_member_access os fd.Access
output_string os " "

if fd.IsStatic then output_string os " static "
if fd.IsStatic then
output_string os " static "

if fd.IsLiteral then output_string os " literal "
if fd.IsLiteral then
output_string os " literal "

if fd.IsSpecialName then
output_string os " specialname rtspecialname "

if fd.IsInitOnly then output_string os " initonly "
if fd.IsInitOnly then
output_string os " initonly "

if fd.NotSerialized then output_string os " notserialized "
if fd.NotSerialized then
output_string os " notserialized "

goutput_typ env os fd.FieldType
output_string os " "
Expand Down Expand Up @@ -740,7 +744,8 @@ let output_code_label os lab = output_string os (formatCodeLabel lab)
let goutput_local env os (l: ILLocal) =
goutput_typ env os l.Type

if l.IsPinned then output_string os " pinned"
if l.IsPinned then
output_string os " pinned"

let goutput_param env os (l: ILParameter) =
match l.Name with
Expand Down Expand Up @@ -985,7 +990,8 @@ let rec goutput_instr env os inst =
let rank = shape.Rank
output_parens (output_array ", " (goutput_typ env)) os (Array.create rank PrimaryAssemblyILGlobals.typ_Int32)
| I_ldelema (ro, _, shape, tok) ->
if ro = ReadonlyAddress then output_string os "readonly. "
if ro = ReadonlyAddress then
output_string os "readonly. "

if shape = ILArrayShape.SingleDimensional then
output_string os "ldelema "
Expand Down Expand Up @@ -1034,7 +1040,8 @@ let rec goutput_instr env os inst =
| _ -> output_string os "<printing for this instruction is not implemented>"

let goutput_ilmbody env os (il: ILMethodBody) =
if il.IsZeroInit then output_string os " .zeroinit\n"
if il.IsZeroInit then
output_string os " .zeroinit\n"

output_string os " .maxstack "
output_i32 os il.MaxStack
Expand Down Expand Up @@ -1067,7 +1074,8 @@ let goutput_mbody is_entrypoint env os (md: ILMethodDef) =
| MethodBody.IL il -> goutput_ilmbody env os il.Value
| _ -> ()

if is_entrypoint then output_string os " .entrypoint"
if is_entrypoint then
output_string os " .entrypoint"

output_string os "\n"
output_string os "}\n"
Expand Down Expand Up @@ -1125,11 +1133,14 @@ let goutput_mdef env os (md: ILMethodDef) =
let menv = ppenv_enter_method (List.length md.GenericParams) env
output_string os " .method "

if md.IsHideBySig then output_string os "hidebysig "
if md.IsHideBySig then
output_string os "hidebysig "

if md.IsReqSecObj then output_string os "reqsecobj "
if md.IsReqSecObj then
output_string os "reqsecobj "

if md.IsSpecialName then output_string os "specialname "
if md.IsSpecialName then
output_string os "specialname "

if md.IsUnmanagedExport then
output_string os "unmanagedexp "
Expand All @@ -1149,13 +1160,17 @@ let goutput_mdef env os (md: ILMethodDef) =
(goutput_params menv) os md.Parameters
output_string os " "

if md.IsSynchronized then output_string os "synchronized "
if md.IsSynchronized then
output_string os "synchronized "

if md.IsMustRun then output_string os "/* mustrun */ "
if md.IsMustRun then
output_string os "/* mustrun */ "

if md.IsPreserveSig then output_string os "preservesig "
if md.IsPreserveSig then
output_string os "preservesig "

if md.IsNoInline then output_string os "noinlining "
if md.IsNoInline then
output_string os "noinlining "

if md.IsAggressiveInline then
output_string os "aggressiveinlining "
Expand Down Expand Up @@ -1255,13 +1270,17 @@ let rec goutput_tdef enc env contents os (cd: ILTypeDef) =
output_string os layout_attr
output_string os " "

if cd.IsSealed then output_string os "sealed "
if cd.IsSealed then
output_string os "sealed "

if cd.IsAbstract then output_string os "abstract "
if cd.IsAbstract then
output_string os "abstract "

if cd.IsSerializable then output_string os "serializable "
if cd.IsSerializable then
output_string os "serializable "

if cd.IsComInterop then output_string os "import "
if cd.IsComInterop then
output_string os "import "

output_sqstring os cd.Name
goutput_gparams env os cd.GenericParams
Expand Down Expand Up @@ -1339,7 +1358,8 @@ let output_assemblyRef os (aref: ILAssemblyRef) =
output_string os " .assembly extern "
output_sqstring os aref.Name

if aref.Retargetable then output_string os " retargetable "
if aref.Retargetable then
output_string os " retargetable "

output_string os " { "
output_option output_hash os aref.Hash
Expand Down
Loading

0 comments on commit 65643c1

Please sign in to comment.