Skip to content

Commit 2f1b09a

Browse files
authored
Merge pull request #14 from azurefx/support_field_setters
Support field setters
2 parents 18b5ace + a37c84d commit 2f1b09a

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

.github/workflows/TagBot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: TagBot
2+
on:
3+
issue_comment:
4+
types:
5+
- created
6+
workflow_dispatch:
7+
jobs:
8+
TagBot:
9+
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: JuliaRegistries/TagBot@v1
13+
with:
14+
token: ${{ secrets.GITHUB_TOKEN }}
15+
ssh: ${{ secrets.DOCUMENTER_KEY }}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ julia> DotNET.unbox(s)
9494
To copy a multidimensional array from `.NET` to Julia, use `collect` method:
9595

9696
```julia
97-
julia> arr = convert(CLRObject, reshape(1:8, 2, 2, 2))
98-
System.Int64[,,]("System.Int64[,,]")
97+
julia> arr = convert(CLRObject, reshape(UnitRange{Int32}(1, 8), 2, 2, 2))
98+
System.Int32[,,]("System.Int32[,,]")
9999

100100
julia> collect(arr)
101-
2×2×2 Array{Int64, 3}:
101+
2×2×2 Array{Int32, 3}:
102102
[:, :, 1] =
103103
1 3
104104
2 4
@@ -199,7 +199,7 @@ To create a delegate from a Julia method, use `delegate` method:
199199
julia> list = ListT.new[T"System.Int64"](1:5)
200200
System.Collections.Generic.List`1[System.Int64]("System.Collections.Generic.List`1[System.Int64]")
201201
202-
julia> list.RemoveAll(delegate(iseven,T"System.Predicate`1[System.Int64]"))
202+
julia> list.RemoveAll(delegate(iseven, T"System.Predicate`1[System.Int64]"))
203203
2
204204
205205
julia> collect(list)

src/operators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ end
9292

9393
function Base.setproperty!(obj::CLRObject, sym::Symbol, val)
9494
ty = clrtypeof(obj)
95-
flags = BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty
95+
flags = BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty | BindingFlags.SetField
9696
if isassignable(T"System.Type", ty)
9797
invokemember(flags, obj, CLRObject(0), sym, val)
9898
else

test/runtests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ end
4545
ref = WeakReference.new(CLRObject(0))
4646
ref.Target = WeakReference
4747
@test T"System.Object, mscorlib".Equals(ref.Target, WeakReference)
48+
49+
# varargs
50+
@test T"System.String".Format("{0}{1}{2}", "i", 18, "n") == "i18n"
51+
52+
# field access
53+
let t = T"System.ValueTuple`1".new[T"System.Int32"](Int32(1))
54+
@test t.Item1 == Int32(1)
55+
t.Item1 = Int32(2)
56+
@test t.Item1 == Int32(2)
57+
end
4858
end
4959

5060
@testset "Generics" begin

0 commit comments

Comments
 (0)