Aart Bluestoke
❔ how to test for invalid chars before xml serialisation?
inside the xml serialiser System.Xml.XmlCharType.IsCharData(char ch) is called.
but XmlCharType is internal, so i can't do that check myself without doing naughty reflection things to bypass visibility barriers.
is there some way i can detect funny chars myself, without cloning that code? Ideally i'd like to do a pre-process pass over the text to handle funky chars (or an exception handler to post-process and retry on exception)
(i'm forced to accept free text user input without an opportunity to reject it - i can't just exception and produce no XML at all here .. at the very least i should be able to detect and handle the junk record ...=)
6 replies
❔ how to supress warning CS8774
The following code throws a warning, how can i suppress it? Even an ! on the end doesn't affect that warning
i want users of this function to know that they have a non-null Potato once M has completed.
I know that an 'await' returns a task and that during the execution of the task the potato might be null, but that is standard reasoning for an async function - if i call an async anything, the results might not be there until the Task Completes ...
https://sharplab.io/#v2:EYLgtghglgdgPgAQEwEYCwAoBAGABAlAOgBEoIBzGAewGcAXKAYxsIGEqATAUwEEYIANgE8aUGgG5MOfCgCskjFIDM+JLla4A3ply7cOvQHlgAKy6M6AflwB9AA5U6EOlQV79GdwG0AslzDAXABOAHKOIQCuAgIAFPxgXFQAZjH2js5UAJSZALoGuggqCAAc+ABsuD4xmVr57rYOTi4AvPgAnLgAYlx0jAAWAArpLtUAhOK4APSTAO4QQTCw5OoAysUA7OsALCCV/oFBuADkaU1UR7hgEfS4fRAAbly4ELjUMAC0MFECuPeCEU8Zn0uDBcFwAB5QBgwciEOoAXzqdUK+FKCDKAB5jGYLAA+Lo9fpDM7VLQIdavLgzXDY8x0ariREYeFAA===
18 replies
❔ is a non-concurrent dictionary concurrent safe under alterations of only value?
Dictionary<string,object> ds;
string x; object z;
var y=ds[x]; // we know 'x' exists as a key.
ds[x]=z; // is it safe to change key x to a different value?
I don't care if other threads see either y or z under this scenario. All i care about is not getting runtime exceptions, or nonsensical results (eg, value for wrong key returned).
I know that modifying the keys in any way is very much not concurrent safe, and is handled correctly.
6 replies