This repo contains the foundational libraries that make up the .NET Core development stack.
carlossanlop on 3.1
[release/3.1] Add RID for Aplin… (compare)
AA\([^)]*\)
.+?
+
instead of *
?
@isobel-cullen - If they're not, you have a pretty dangerous race condition.
ValueTask
is mutable, more or less, but callers aren't supposed to muck with it (and are supposed to ignore it after successfully awaiting it, so don't have to deal with other modifications anyways).
hey, guys! can't figure it out how to create and obtain the value of object property in new writable JSON:
Person person = new() { Age = 22, Name = "Linda" };
JsonObject json = new()
{
["person"] = JsonValue.Create(person)
};
WriteLine((int)json["person"]["Age"]);
however, I get the error:
Unhandled exception. System.InvalidOperationException: The node must be of type 'JsonObject'.
at System.Text.Json.Node.JsonNode.AsObject() in System.Text.Json.dll:token 0x60005bb+0x20
at System.Text.Json.Node.JsonNode.get_Item(String propertyName) in System.Text.Json.dll:token 0x60005c5+0x0
at ConsoleApp.Program.TestJsonNodes() in E:\Projects\ConsoleApp\Program.cs:line 121
at ConsoleApp.Program.Main(String[] args) in E:\Projects\ConsoleApp\Program.cs:line 81
Function GetHash(sourceStr As String) As String
Dim b = ASCIIEncoding.ASCII.GetBytes(sourceStr)
Dim hash = New MD5CryptoServiceProvider().ComputeHash(b)
Dim sb As New StringBuilder(hash.Length)
For i = 0 To hash.Length - 1
sb.Append(hash(i).ToString("X2"))
Next
Return sb.ToString()
End Function
@Eugene was your intent to use an already-instantiated POCO?
If not, create the JsonObject directly
JsonObject jObject = new()
{
["person"] = new JsonObject()
{
["Age"] = 22,
["Name"] = "Linda"
}
};
If the intent was to use the POCO instance and not modify it as a JsonObject you can treat the POCO as a JsonValue:
Person person = new() { Age = 22, Name = "Linda" };
JsonObject jObject = new()
{
["person"] = JsonValue.Create(person)
};
If the intent was to use the POCO instance + treat it as a modifiable JsonObject, you'll need to serialize+deserialize:
Person person = new() { Age = 22, Name = "Linda" };
JsonObject jObject = new()
{
["person"] = JsonNode.Parse(JsonSerializer.Serialize(person)).AsObject()
};
Note that a new "CreateFromObject" helper could be added to JsonObject to make this easier for the latter sample:
Person person = new() { Age = 22, Name = "Linda" };
JsonObject jObject = new()
{
["person"] = JsonObject.CreateFromObject(person)
};
I am using this function to get hash code to use in a test method. It is supposed to give the same hash for the same source string every time. That is true as long as I run on my win 7 32 bit machine, but when I ran the test on a win 7 64 bit machine it failed because the Hash function returned another hash for the same source string!
Why? Does the DM5 depend on the machine, the OS or the 32/64 bit architecture? Ir this is related to the ASCII encoding or ToString("X2")?