Skip to content

Update fantomas to 7.0.1 #18400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"rollForward": true
},
"fantomas": {
"version": "6.2.3",
"version": "7.0.1",
"commands": [
"fantomas"
],
Expand All @@ -59,4 +59,4 @@
"rollForward": false
}
}
}
}
56 changes: 28 additions & 28 deletions src/Compiler/AbstractIL/ilnativeres.fs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ type CvtResFile() =
pAdditional.DataSize <- cbData
pAdditional.pstringType <- CvtResFile.ReadStringOrID reader
pAdditional.pstringName <- CvtResFile.ReadStringOrID reader
stream.Position <- stream.Position + 3L &&& ~~~ 3L
stream.Position <- stream.Position + 3L &&& ~~~3L
pAdditional.DataVersion <- reader.ReadUInt32()
pAdditional.MemoryFlags <- reader.ReadUInt16()
pAdditional.LanguageId <- reader.ReadUInt16()
pAdditional.Version <- reader.ReadUInt32()
pAdditional.Characteristics <- reader.ReadUInt32()
pAdditional.data <- Array.zeroCreate (int pAdditional.DataSize)
reader.Read(pAdditional.data, 0, pAdditional.data.Length) |> ignore<int>
stream.Position <- stream.Position + 3L &&& ~~~ 3L
stream.Position <- stream.Position + 3L &&& ~~~3L

if
pAdditional.pstringType.theString = Unchecked.defaultof<_>
Expand Down Expand Up @@ -174,6 +174,7 @@ type SectionCharacteristics =
type ResourceSection() =
new(sectionBytes: byte[], relocations: uint32[]) as this =
(ResourceSection())

then
Debug.Assert(sectionBytes :> obj <> Unchecked.defaultof<_>)
Debug.Assert(relocations :> obj <> Unchecked.defaultof<_>)
Expand Down Expand Up @@ -374,13 +375,8 @@ type VersionHelper() =
///
/// <returns>True when parsing succeeds completely (i.e. every character in the string was consumed), false otherwise.</returns>
static member private TryParse
(
s: string,
allowWildcard: bool,
maxValue: uint16,
allowPartialParse: bool,
[<Out>] version: byref<Version>
) =
(s: string, allowWildcard: bool, maxValue: uint16, allowPartialParse: bool, [<Out>] version: byref<Version>)
=
Debug.Assert(not allowWildcard || maxValue < UInt16.MaxValue)

if String.IsNullOrWhiteSpace s then
Expand Down Expand Up @@ -520,20 +516,24 @@ type VersionResourceSerializer() =

member val private _isDll = Unchecked.defaultof<bool> with get, set

new(isDll: bool,
comments: string,
companyName: string,
fileDescription: string,
fileVersion: string,
internalName: string,
legalCopyright: string,
legalTrademark: string,
originalFileName: string,
productName: string,
productVersion: string,
assemblyVersion: Version) as this =
new
(
isDll: bool,
comments: string,
companyName: string,
fileDescription: string,
fileVersion: string,
internalName: string,
legalCopyright: string,
legalTrademark: string,
originalFileName: string,
productName: string,
productVersion: string,
assemblyVersion: Version
) as this =

VersionResourceSerializer()

then
this._isDll <- isDll
this._commentsContents <- comments
Expand Down Expand Up @@ -620,7 +620,7 @@ type VersionResourceSerializer() =
static member private PadKeyLen(cb: int) =
VersionResourceSerializer.PadToDword(cb + 3 * sizeof<WORD>) - 3 * sizeof<WORD>

static member private PadToDword(cb: int) = cb + 3 &&& ~~~ 3
static member private PadToDword(cb: int) = cb + 3 &&& ~~~3

static member val private HDRSIZE = (int (3 * sizeof<uint16>)) with get, set

Expand Down Expand Up @@ -667,7 +667,7 @@ type VersionResourceSerializer() =
let mutable (sum: int) = 0

for verString in this.GetVerStrings() do
sum <- sum + 3 &&& ~~~ 3
sum <- sum + 3 &&& ~~~3
sum <- sum + VersionResourceSerializer.SizeofVerString(verString.Key, verString.Value)

sum
Expand Down Expand Up @@ -801,7 +801,7 @@ type VersionResourceSerializer() =

for entry in this.GetVerStrings() do
let mutable writerPos = writer.BaseStream.Position
writer.Write(Array.zeroCreate (int ((writerPos + 3L) &&& ~~~ 3L - writerPos)): byte[])
writer.Write(Array.zeroCreate (int ((writerPos + 3L) &&& ~~~3L - writerPos)): byte[])
Debug.Assert(entry.Value <> Unchecked.defaultof<_>)
VersionResourceSerializer.WriteVersionString(entry, writer)

Expand Down Expand Up @@ -861,7 +861,7 @@ type Win32ResourceConversions() =
let mutable (i: uint16) = 0us

while (i < count) do
resStream.Position <- resStream.Position + 3L &&& ~~~ 3L
resStream.Position <- resStream.Position + 3L &&& ~~~3L
resWriter.Write iconDirEntries[(int i)].dwBytesInRes
resWriter.Write 0x00000020u
resWriter.Write 0xFFFFus
Expand All @@ -878,7 +878,7 @@ type Win32ResourceConversions() =
i <- i + 1us

let mutable (RT_GROUP_ICON: WORD) = (RT_ICON + 11us)
resStream.Position <- resStream.Position + 3L &&& ~~~ 3L
resStream.Position <- resStream.Position + 3L &&& ~~~3L
resWriter.Write(uint32 (3 * sizeof<WORD> + int count * 14))
resWriter.Write 0x00000020u
resWriter.Write 0xFFFFus
Expand Down Expand Up @@ -933,7 +933,7 @@ type Win32ResourceConversions() =
let comments = (defaultArg comments) Unchecked.defaultof<_>
let companyName = (defaultArg companyName) Unchecked.defaultof<_>
let mutable resWriter = new BinaryWriter(resStream, Encoding.Unicode)
resStream.Position <- resStream.Position + 3L &&& ~~~ 3L
resStream.Position <- resStream.Position + 3L &&& ~~~3L
let mutable (RT_VERSION: DWORD) = 16u

let mutable ver =
Expand Down Expand Up @@ -970,7 +970,7 @@ type Win32ResourceConversions() =
Debug.Assert(resStream.Position - startPos = int64 dataSize + int64 headerSize)

static member AppendManifestToResourceStream(resStream: Stream, manifestStream: Stream, isDll: bool) =
resStream.Position <- resStream.Position + 3L &&& ~~~ 3L (* ERROR UnknownPrefixOperator "~" *)
resStream.Position <- resStream.Position + 3L &&& ~~~3L (* ERROR UnknownPrefixOperator "~" *)
let mutable (RT_MANIFEST: WORD) = 24us
let mutable resWriter = new BinaryWriter(resStream)
resWriter.Write(uint32 manifestStream.Length)
Expand Down
12 changes: 2 additions & 10 deletions src/Compiler/AbstractIL/ilread.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4180,16 +4180,8 @@ and seekReadTopExportedTypes (ctxt: ILMetadataReader) =

// Note, pectxtEager and pevEager must not be captured by the results of this function
let openMetadataReader
(
fileName,
mdfile: BinaryFile,
metadataPhysLoc,
peinfo,
pectxtEager: PEReader,
pevEager,
pectxtCaptured,
reduceMemoryUsage
) =
(fileName, mdfile: BinaryFile, metadataPhysLoc, peinfo, pectxtEager: PEReader, pevEager, pectxtCaptured, reduceMemoryUsage)
=
let mdv = mdfile.GetView()
let magic = seekReadUInt16AsInt32 mdv metadataPhysLoc

Expand Down
13 changes: 5 additions & 8 deletions src/Compiler/AbstractIL/ilreflect.fs
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,7 @@ type OpCode with
member opcode.RefEmitName =
match opcode.Name with
| null -> ""
| name ->
(string (Char.ToUpper(name[0])) + name[1..])
.Replace(".", "_")
.Replace("_i4", "_I4")
| name -> (string (Char.ToUpper(name[0])) + name[1..]).Replace(".", "_").Replace("_i4", "_I4")

type ILGenerator with

Expand Down Expand Up @@ -713,7 +710,7 @@ let rec convTypeSpec cenv emEnv preferCreated (tspec: ILTypeSpec) =

and convTypeAux cenv emEnv preferCreated ty =
match ty with
| ILType.Void -> !! Type.GetType("System.Void")
| ILType.Void -> !!Type.GetType("System.Void")
| ILType.Array(shape, eltType) ->
let baseT = convTypeAux cenv emEnv preferCreated eltType
let nDims = shape.Rank
Expand Down Expand Up @@ -1491,7 +1488,7 @@ let rec emitInstr cenv (modB: ModuleBuilder) emEnv (ilG: ILGenerator) instr =
ilG.EmitAndLog(OpCodes.Ldelema, convType cenv emEnv ty)
else
let arrayTy = convType cenv emEnv (ILType.Array(shape, ty))
let elemTy = !! arrayTy.GetElementType()
let elemTy = !!arrayTy.GetElementType()
let argTys = Array.create shape.Rank typeof<int>
let retTy = elemTy.MakeByRefType()

Expand All @@ -1517,7 +1514,7 @@ let rec emitInstr cenv (modB: ModuleBuilder) emEnv (ilG: ILGenerator) instr =
ilG.EmitAndLog(OpCodes.Stelem, convType cenv emEnv ty)
else
let arrayTy = convType cenv emEnv (ILType.Array(shape, ty))
let elemTy = !! arrayTy.GetElementType()
let elemTy = !!arrayTy.GetElementType()

let meth =
modB.GetArrayMethodAndLog(
Expand Down Expand Up @@ -2497,7 +2494,7 @@ let mkDynamicAssemblyAndModule (assemblyName: string, optimize, collectible) =
let daType = typeof<System.Diagnostics.DebuggableAttribute>

let daCtor =
!! daType.GetConstructor([| typeof<System.Diagnostics.DebuggableAttribute.DebuggingModes> |])
!!daType.GetConstructor([| typeof<System.Diagnostics.DebuggableAttribute.DebuggingModes> |])

let daBuilder =
CustomAttributeBuilder(
Expand Down
6 changes: 2 additions & 4 deletions src/Compiler/AbstractIL/ilsupp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,7 @@ let unlinkResource (ulLinkedResourceBaseRVA: int32) (pbLinkedResource: byte[]) =
for i = 0 to (nResNodes - 1) do
size <-
size
+ pResNodes[i]
.Save(ulLinkedResourceBaseRVA, pbLinkedResource, Unchecked.defaultof<byte[]>, 0)
+ pResNodes[i].Save(ulLinkedResourceBaseRVA, pbLinkedResource, Unchecked.defaultof<byte[]>, 0)

let pResBuffer = Bytes.zeroCreate size

Expand All @@ -670,7 +669,6 @@ let unlinkResource (ulLinkedResourceBaseRVA: int32) (pbLinkedResource: byte[]) =
for i = 0 to (nResNodes - 1) do
resBufferOffset <-
resBufferOffset
+ pResNodes[i]
.Save(ulLinkedResourceBaseRVA, pbLinkedResource, pResBuffer, resBufferOffset)
+ pResNodes[i].Save(ulLinkedResourceBaseRVA, pbLinkedResource, pResBuffer, resBufferOffset)

pResBuffer
Original file line number Diff line number Diff line change
Expand Up @@ -3083,9 +3083,7 @@ let TcComputationExpression (cenv: TcFileState) env (overallTy: OverallTy) tpenv
TranslateComputationExpression ceenv CompExprTranslationPass.Initial hasCustomOperations (LazyWithContext.NotLazy([], env)) comp id

let mDelayOrQuoteOrRun =
mBuilderVal
.NoteSourceConstruct(NotedSourceConstruct.DelayOrQuoteOrRun)
.MakeSynthetic()
mBuilderVal.NoteSourceConstruct(NotedSourceConstruct.DelayOrQuoteOrRun).MakeSynthetic()

// Add a call to 'Delay' if the method is present
let delayedExpr =
Expand Down
28 changes: 16 additions & 12 deletions src/Compiler/CodeGen/EraseUnions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -742,12 +742,14 @@ let mkMethodsAndPropertiesForFields
basicProps, basicMethods

let convAlternativeDef
(addMethodGeneratedAttrs,
addPropertyGeneratedAttrs,
addPropertyNeverAttrs,
addFieldGeneratedAttrs,
addFieldNeverAttrs,
mkDebuggerTypeProxyAttribute)
(
addMethodGeneratedAttrs,
addPropertyGeneratedAttrs,
addPropertyNeverAttrs,
addFieldGeneratedAttrs,
addFieldNeverAttrs,
mkDebuggerTypeProxyAttribute
)
(g: TcGlobals)
num
(td: ILTypeDef)
Expand Down Expand Up @@ -1255,12 +1257,14 @@ let convAlternativeDef
baseMakerMeths, baseMakerProps, altUniqObjMeths, typeDefs, altDebugTypeDefs, altNullaryFields

let mkClassUnionDef
(addMethodGeneratedAttrs,
addPropertyGeneratedAttrs,
addPropertyNeverAttrs,
addFieldGeneratedAttrs: ILFieldDef -> ILFieldDef,
addFieldNeverAttrs: ILFieldDef -> ILFieldDef,
mkDebuggerTypeProxyAttribute)
(
addMethodGeneratedAttrs,
addPropertyGeneratedAttrs,
addPropertyNeverAttrs,
addFieldGeneratedAttrs: ILFieldDef -> ILFieldDef,
addFieldNeverAttrs: ILFieldDef -> ILFieldDef,
mkDebuggerTypeProxyAttribute
)
(g: TcGlobals)
tref
(td: ILTypeDef)
Expand Down
Loading