Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

Commented Issue: Restricted access to non-public accessors of public properties is not enforced [71]

0
0
Hi, I'm having an issue with exposed host object which has a property with public getter and private setter.
For example, I can put a script like "SomeObject.Name = ...". Is there a way to prevent this?

```
public class SomeObject
{
private string _name;
public string Name
{
get { return this._name; }
private set { this._name = value; }
}
}
```

And also, If I try to expose an object instance as interface, I still be able to access to the object's members.
For example,
```
public class SomeObject : IInterface
{
private string _name;
public string Name
{
get { return this.Name; }
private set { this._name = value; }
}

public string ToSomeString()
{
return this._name;
}
}

public interface IInterface
{
string ToSomeString();
}
```
```
IInterface obj = new SomeObject();
Engine.AddHostObject("O", obj);
```

I can put script like O.Name = “A”.

Thank you
Comments: Hi, thank you so much. I was thinking that I can introduce a proxy pattern to expose an interface. It also can limit the access of non-public properties. Talking about the assembly loading issue. I did break into ClearScript source code. Microsoft.ClearScript.Util.AssemblyHelpers is trying to load every assembly at the first launching if "AssemblyTable.bin" doesn't exist. You may check out AssemblyHelpers.BuildAssemblyTable(). But anyway, it's not a bug. It's just not that responsive with my computer which has a lot of dlls in "Temporary ASP.NET Files". Thank you for you helping.

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images