Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4720fac
Initial test
edgarfgp May 21, 2024
e14eb37
Update record check for targets
edgarfgp May 21, 2024
f0cd5d5
More tests
edgarfgp May 21, 2024
f42a88c
Merge branch 'main' into attribute-targets-on-records
edgarfgp May 22, 2024
ffb497b
Check Record fields
edgarfgp May 22, 2024
669ee19
release notes
edgarfgp May 22, 2024
670972a
Merge branch 'main' into attribute-targets-on-records
edgarfgp May 22, 2024
d43956f
Extend DefaultValueAttribute to use AttributeTargets.Property
edgarfgp May 22, 2024
cd582b6
revert DefaultValueAttribute changes
edgarfgp May 23, 2024
74e1342
TcFieldDecl
edgarfgp May 23, 2024
071611a
update tests
edgarfgp May 23, 2024
476f236
Merge branch 'main' into attribute-targets-on-records
edgarfgp Jun 10, 2024
3ea80b3
update tests
edgarfgp Jun 10, 2024
6e555a5
update test
edgarfgp Jun 11, 2024
5a0b1c1
Update StructAttribute to also AttributeTargets.Class
edgarfgp Jun 11, 2024
389439c
Merge branch 'main' into attribute-targets-on-records
edgarfgp Jun 12, 2024
0062acb
Update 8.0.400.md
psfinaki Jun 12, 2024
a0f3acf
Add clarifying comment
edgarfgp Jun 13, 2024
a63a322
Merge branch 'main' into attribute-targets-on-records
edgarfgp Jun 13, 2024
cc7cc4a
Merge branch 'main' into attribute-targets-on-records
edgarfgp Jun 13, 2024
207ac3b
Merge branch 'main' into attribute-targets-on-records
edgarfgp Jun 14, 2024
993958e
Merge branch 'main' into attribute-targets-on-records
edgarfgp Jun 17, 2024
be11382
Merge branch 'main' into attribute-targets-on-records
edgarfgp Jul 3, 2024
5c6c7c8
We do not check for RQA attribute
edgarfgp Jul 3, 2024
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
Prev Previous commit
Next Next commit
Check Record fields
  • Loading branch information
edgarfgp committed May 22, 2024
commit ffb497bbb4cbbf42fa6697f75b1dafd2fe9e997d
7 changes: 6 additions & 1 deletion src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,12 @@ module TcRecdUnionAndEnumDeclarations =
let TcFieldDecl (cenv: cenv) env parent isIncrClass tpenv (isStatic, synAttrs, id: Ident, nameGenerated, ty, isMutable, xmldoc, vis) =
let g = cenv.g
let m = id.idRange
let attrs, _ = TcAttributesWithPossibleTargets false cenv env AttributeTargets.FieldDecl synAttrs
let attrs, _ =
if g.langVersion.SupportsFeature(LanguageFeature.EnforceAttributeTargets) then
TcAttributesWithPossibleTargets false cenv env AttributeTargets.Property synAttrs
else
TcAttributesWithPossibleTargets false cenv env AttributeTargets.FieldDecl synAttrs

let attrsForProperty, attrsForField = attrs |> List.partition (fun (attrTargets, _) -> (attrTargets &&& AttributeTargets.Property) <> enum 0)
let attrsForProperty = (List.map snd attrsForProperty)
let attrsForField = (List.map snd attrsForField)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@ type PropertyLevelAttribute() =
type U =
| [<PropertyLevel>] A
| [<PropertyLevel>] B

[<AttributeUsage(AttributeTargets.Property)>]
type Name(x: string) =
inherit Attribute()
member _.value = x

type User =
{ [<Name("id")>]
Id: int
[<Name("email")>]
Email: string
[<Name("organization_id")>]
OrganizationId: option<string> }
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ module CustomAttributes_AttributeUsage =
|> withDiagnostics [
(Error 842, Line 14, Col 5, Line 14, Col 18, "This attribute is not valid for use on this language element")
(Error 842, Line 15, Col 5, Line 15, Col 25, "This attribute is not valid for use on this language element")
(Error 842, Line 23, Col 9, Line 23, Col 19, "This attribute is not valid for use on this language element")
(Error 842, Line 25, Col 9, Line 25, Col 22, "This attribute is not valid for use on this language element")
(Error 842, Line 27, Col 9, Line 27, Col 32, "This attribute is not valid for use on this language element")
]

// SOURCE=E_AttributeTargetIsCtor01.fs # E_AttributeTargetIsCtor01.fs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,17 @@ type PropertyOrFieldLevelAttribute() =

type SomeUnion =
| [<PropertyLevel>] Case1 of int // Should fail
| [<PropertyOrFieldLevel>] Case2 of int // Should fail
| [<PropertyOrFieldLevel>] Case2 of int // Should fail

[<AttributeUsage(AttributeTargets.Field)>]
type Name(x: string) =
inherit Attribute()
member _.value = x

type User =
{ [<Name("id")>]
Id: int
[<Name("email")>]
Email: string
[<Name("organization_id")>]
OrganizationId: option<string> }