Skip to content

Commit

Permalink
disable fsharp_space_before_uppercase_invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
samritchie committed Feb 2, 2024
1 parent c18a0d9 commit 91d9646
Show file tree
Hide file tree
Showing 31 changed files with 1,043 additions and 1,055 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fsharp_space_before_lowercase_invocation=true
# false: x.ToString()
# true: x.ToString ()
# default false
fsharp_space_before_uppercase_invocation=true
fsharp_space_before_uppercase_invocation=false

# false: new Ship(withBeans)
# true: new Ship (withBeans)
Expand Down
140 changes: 70 additions & 70 deletions src/FSharp.AWS.DynamoDB/Expression/ConditionalExpr.fs

Large diffs are not rendered by default.

98 changes: 49 additions & 49 deletions src/FSharp.AWS.DynamoDB/Expression/ExprCommon.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ type AttributeId =
append id.RootId

for nf in id.NestedAttributes do
append <| nf.Print ())
append <| nf.Print())

member id.Name =
mkString (fun append ->
append id.RootId

for nf in id.NestedAttributes do
append <| nf.Print ())
append <| nf.Print())

member id.Tokens =
seq {
yield id.RootName
yield! id.NestedAttributes |> Seq.map (fun nf -> nf.Print ())
yield! id.NestedAttributes |> Seq.map (fun nf -> nf.Print())
}

member id.IsHashKey =
Expand Down Expand Up @@ -96,10 +96,10 @@ type AttributeId =
| :? string as f -> FField f
| :? int as i ->
if i < 0 then
raise <| ArgumentOutOfRangeException ()
raise <| ArgumentOutOfRangeException()
else
FIndex i
| _ -> raise <| new InvalidCastException ()
| _ -> raise <| new InvalidCastException()
| _ -> nf

{ id with NestedAttributes = id.NestedAttributes |> List.map applyField }
Expand Down Expand Up @@ -129,30 +129,30 @@ type QuotedAttribute =
/// Gets the pickler corresponding to the type pointed to by the attribute path
member ap.Pickler =
match ap with
| Root (rp, _) -> rp.Pickler
| Nested (rp, _) -> rp.Pickler
| Item (_, pickler, _) -> pickler
| Optional (p, _) -> p
| Root(rp, _) -> rp.Pickler
| Nested(rp, _) -> rp.Pickler
| Item(_, pickler, _) -> pickler
| Optional(p, _) -> p

/// Gets the root record property of given attribute path
member ap.RootProperty =
let rec aux ap =
match ap with
| Root (rp, _) -> rp
| Nested (_, p) -> aux p
| Item (_, _, p) -> aux p
| Optional (_, p) -> aux p
| Root(rp, _) -> rp
| Nested(_, p) -> aux p
| Item(_, _, p) -> aux p
| Optional(_, p) -> aux p

aux ap

/// Gets an attribute identifier for given Quoted attribute instace
member ap.Id =
let rec getTokens acc ap =
match ap with
| Nested (rp, p) -> getTokens (FField rp.Name :: acc) p
| Item (nf, _, p) -> getTokens (nf :: acc) p
| Optional (_, p) -> getTokens acc p
| Root (rp, schema) ->
| Nested(rp, p) -> getTokens (FField rp.Name :: acc) p
| Item(nf, _, p) -> getTokens (nf :: acc) p
| Optional(_, p) -> getTokens acc p
| Root(rp, schema) ->
{ RootId = rp.AttrId
RootName = rp.Name
NestedAttributes = acc
Expand All @@ -164,14 +164,14 @@ type QuotedAttribute =
member ap.Iter(f: Pickler -> unit) =
let rec aux ap =
match ap with
| Root (rp, _) -> f rp.Pickler
| Nested (rp, p) ->
| Root(rp, _) -> f rp.Pickler
| Nested(rp, p) ->
f rp.Pickler
aux p
| Item (_, pickler, p) ->
| Item(_, pickler, p) ->
f pickler
aux p
| Optional (pickler, p) ->
| Optional(pickler, p) ->
f pickler
aux p

Expand All @@ -196,32 +196,32 @@ type QuotedAttribute =

let rec extractProps props e =
match e with
| PropertyGet (Some (Var r'), p, []) when record = r' ->
| PropertyGet(Some(Var r'), p, []) when record = r' ->
match tryGetPropInfo info.Properties (List.isEmpty props) p with
| None -> None
| Some rp ->
let root = Root (rp, info.GetPropertySchemata rp.Name)
let root = Root(rp, info.GetPropertySchemata rp.Name)
mkAttrPath root rp.NestedRecord props

| SpecificProperty <@ fun (t: _ option) -> t.Value @> (Some e, [ et ], _) -> extractProps (Choice2Of3 et :: props) e

| SpecificProperty <@ fun (r: _ ref) -> r.Value @> (Some e, _, _) ->
let p = e.Type.GetProperty ("contents")
let p = e.Type.GetProperty("contents")
extractProps (Choice1Of3 p :: props) e

| PropertyGet (Some e, p, []) -> extractProps (Choice1Of3 p :: props) e
| PropertyGet(Some e, p, []) -> extractProps (Choice1Of3 p :: props) e

| SpecificCall2 <@ fst @> (None, _, _, [ e ]) ->
let p = e.Type.GetProperty ("Item1")
let p = e.Type.GetProperty("Item1")
extractProps (Choice1Of3 p :: props) e

| SpecificCall2 <@ snd @> (None, _, _, [ e ]) ->
let p = e.Type.GetProperty ("Item2")
let p = e.Type.GetProperty("Item2")
extractProps (Choice1Of3 p :: props) e

| SpecificCall2 <@ Option.get @> (None, _, [ et ], [ e ]) -> extractProps (Choice2Of3 et :: props) e

| IndexGet (e, et, i) -> extractProps (Choice3Of3 (et, i) :: props) e
| IndexGet(e, et, i) -> extractProps (Choice3Of3(et, i) :: props) e

| _ -> None

Expand All @@ -231,28 +231,28 @@ type QuotedAttribute =
| Choice1Of3 p :: tail, Some rI ->
match tryGetPropInfo rI (List.isEmpty tail) p with
| None -> None
| Some rp -> mkAttrPath (Nested (rp, acc)) rp.NestedRecord tail
| Some rp -> mkAttrPath (Nested(rp, acc)) rp.NestedRecord tail

| Choice2Of3 opt :: tail, None ->
let pickler = Pickler.resolveUntyped opt
mkAttrPath (Optional (pickler, acc)) ctx tail
mkAttrPath (Optional(pickler, acc)) ctx tail

| Choice3Of3 (et, ie) :: tail, None ->
| Choice3Of3(et, ie) :: tail, None ->
let pickler = Pickler.resolveUntyped et

let ctx =
match box pickler with
| :? IRecordPickler as rc -> Some rc.Properties
| _ -> None

let inline mkAttrPath indexV = mkAttrPath (Item (indexV, pickler, acc)) ctx tail
let inline mkAttrPath indexV = mkAttrPath (Item(indexV, pickler, acc)) ctx tail

match ie with
| _ when ie.IsClosed ->
match evalRaw ie: obj with
| :? int as i ->
if i < 0 then
raise <| ArgumentOutOfRangeException ()
raise <| ArgumentOutOfRangeException()
else
mkAttrPath (FIndex i)
| :? string as f -> mkAttrPath (FField f)
Expand All @@ -266,10 +266,10 @@ type QuotedAttribute =

/// Wrapper API for writing attribute names and values for Dynamo query expressions
type AttributeWriter(names: Dictionary<string, string>, values: Dictionary<string, AttributeValue>) =
static let cmp = new AttributeValueComparer ()
let vcontents = new Dictionary<AttributeValue, string> (cmp)
static let cmp = new AttributeValueComparer()
let vcontents = new Dictionary<AttributeValue, string>(cmp)

new() = new AttributeWriter (new Dictionary<_, _> (), new Dictionary<_, _> ())
new() = new AttributeWriter(new Dictionary<_, _>(), new Dictionary<_, _>())

member __.Names = names
member __.Values = values
Expand All @@ -281,8 +281,8 @@ type AttributeWriter(names: Dictionary<string, string>, values: Dictionary<strin
found
else
let id = sprintf ":val%d" values.Count
vcontents.Add (av, id)
values.Add (id, av)
vcontents.Add(av, id)
values.Add(id, av)
id

member __.WriteAttibute(attr: AttributeId) =
Expand All @@ -291,12 +291,12 @@ type AttributeWriter(names: Dictionary<string, string>, values: Dictionary<strin

/// Recognizes exprs of shape <@ fun p1 p2 ... -> body @>
let extractExprParams (recordInfo: RecordTableInfo) (expr: Expr) =
let vars = new Dictionary<Var, int> ()
let vars = new Dictionary<Var, int>()

let rec aux i expr =
match expr with
| Lambda (v, body) when v.Type <> recordInfo.Type ->
vars.Add (v, i)
| Lambda(v, body) when v.Type <> recordInfo.Type ->
vars.Add(v, i)
aux (i + 1) body
| _ -> expr

Expand All @@ -318,24 +318,24 @@ type private AttributeNode = { Value: string; Children: ResizeArray<AttributeNod

/// Detects conflicts in a collection of attribute paths
let tryFindConflictingPaths (attrs: seq<AttributeId>) =
let root = new ResizeArray<AttributeNode> ()
let root = new ResizeArray<AttributeNode>()

let tryAppendPath (attr: AttributeId) =
let tokens = attr.Tokens
let enum = tokens.GetEnumerator ()
let enum = tokens.GetEnumerator()
let mutable ctx = root
let mutable isNodeAdded = false
let mutable isLeafFound = false
let acc = new ResizeArray<_> ()
let acc = new ResizeArray<_>()

while not isLeafFound && enum.MoveNext () do
while not isLeafFound && enum.MoveNext() do
let t = enum.Current

let child =
match ctx.FindIndex (fun n -> n.Value = t) with
match ctx.FindIndex(fun n -> n.Value = t) with
| -1 ->
isNodeAdded <- true
let ch = { Value = t; Children = new ResizeArray<_> () }
let ch = { Value = t; Children = new ResizeArray<_>() }
ctx.Add ch
ch

Expand All @@ -353,14 +353,14 @@ let tryFindConflictingPaths (attrs: seq<AttributeId>) =
let concat xs = String.concat "" xs

if isLeafFound then
Some (concat tokens, concat acc)
Some(concat tokens, concat acc)
elif not isNodeAdded then
while ctx.Count > 0 do
let ch = ctx.[0]
acc.Add ch.Value
ctx <- ch.Children

Some (concat tokens, concat acc)
Some(concat tokens, concat acc)

else
None
Expand Down
18 changes: 9 additions & 9 deletions src/FSharp.AWS.DynamoDB/Expression/ExpressionContainers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open FSharp.AWS.DynamoDB.ProjectionExpr
/// Represents a condition expression for a given record type
[<Sealed; AutoSerializable(false)>]
type ConditionExpression<'TRecord> internal (cond: ConditionalExpression) =
let data = lazy (cond.GetDebugData ())
let data = lazy (cond.GetDebugData())
/// Gets whether given conditional is a valid key condition
member __.IsKeyConditionCompatible = cond.IsKeyConditionCompatible
/// Gets the infered local secondary index for the query, if applicable
Expand Down Expand Up @@ -46,28 +46,28 @@ type ConditionExpression =
static member And(left: ConditionExpression<'TRecord>, right: ConditionExpression<'TRecord>) =
let qExpr = QueryExpr.EAnd left.Conditional.QueryExpr right.Conditional.QueryExpr
ensureNotTautological qExpr
new ConditionExpression<'TRecord> ({ QueryExpr = qExpr; KeyCondition = extractKeyCondition qExpr; NParams = 0 })
new ConditionExpression<'TRecord>({ QueryExpr = qExpr; KeyCondition = extractKeyCondition qExpr; NParams = 0 })

/// <summary>
/// Applies the OR operation on two conditionals
/// </summary>
static member Or(left: ConditionExpression<'TRecord>, right: ConditionExpression<'TRecord>) =
let qExpr = QueryExpr.EOr left.Conditional.QueryExpr right.Conditional.QueryExpr
ensureNotTautological qExpr
new ConditionExpression<'TRecord> ({ QueryExpr = qExpr; KeyCondition = extractKeyCondition qExpr; NParams = 0 })
new ConditionExpression<'TRecord>({ QueryExpr = qExpr; KeyCondition = extractKeyCondition qExpr; NParams = 0 })

/// <summary>
/// Applies the NOT operation on a conditional
/// </summary>
static member Not(conditional: ConditionExpression<'TRecord>) =
let qExpr = QueryExpr.ENot conditional.Conditional.QueryExpr
ensureNotTautological qExpr
new ConditionExpression<'TRecord> ({ QueryExpr = qExpr; KeyCondition = extractKeyCondition qExpr; NParams = 0 })
new ConditionExpression<'TRecord>({ QueryExpr = qExpr; KeyCondition = extractKeyCondition qExpr; NParams = 0 })

/// Represents an update expression for a given record type
[<Sealed; AutoSerializable(false)>]
type UpdateExpression<'TRecord> internal (updateOps: UpdateOperations) =
let data = lazy (updateOps.GetDebugData ())
let data = lazy (updateOps.GetDebugData())
/// Internal update expression object
member internal __.UpdateOps = updateOps
/// DynamoDB update expression string
Expand All @@ -84,7 +84,7 @@ type UpdateExpression<'TRecord> internal (updateOps: UpdateOperations) =

override __.GetHashCode() = hash updateOps.UpdateOps

static member (&&&)(this: UpdateExpression<'TRecord>, that: UpdateExpression<'TRecord>) = UpdateExpression.Combine (this, that)
static member (&&&)(this: UpdateExpression<'TRecord>, that: UpdateExpression<'TRecord>) = UpdateExpression.Combine(this, that)

and UpdateExpression =
/// Combines a collection of compatible update expressions into a single expression.
Expand All @@ -102,16 +102,16 @@ and UpdateExpression =
|> tryFindConflictingPaths
with
| None -> ()
| Some (p1, p2) ->
| Some(p1, p2) ->
let msg = sprintf "found conflicting paths '%s' and '%s' being accessed in update expression." p1 p2
invalidArg "expr" msg

new UpdateExpression<'TRecord> ({ UpdateOps = uops; NParams = 0 })
new UpdateExpression<'TRecord>({ UpdateOps = uops; NParams = 0 })

/// Represents a projection expression for a given record type
[<Sealed; AutoSerializable(false)>]
type ProjectionExpression<'TRecord, 'TProjection> internal (expr: ProjectionExpr) =
let data = lazy (expr.GetDebugData ())
let data = lazy (expr.GetDebugData())
/// Internal projection expression object
member internal __.ProjectionExpr = expr
/// DynamoDB projection expression string
Expand Down
Loading

0 comments on commit 91d9646

Please sign in to comment.