Note that there are some explanatory texts on larger screens.

plurals
  1. POserialize obfuscated class C#
    text
    copied!<p>I currently have a helper class that I am using to obfuscate a static class that keeps track of high scores in a game I am working on. I am using Eazfuscator on my release and found that when my scores were being serialized, this exception was thrown. ArgumentException Identifier ' ' is not CLS-compliant. </p> <p>Is there a way I can store my list of high scores in my helper class and still be able to serialize it after obfuscation? </p> <pre><code>try { GameHighScore highScoreHelper = new GameHighScore(); highScoreHelper.CreateGameHighScore(highScore); XmlSerializer serializer = new XmlSerializer(typeof(GameHighScore)); serializer.Serialize(stream, highScoreHelper); } catch(Exception e) { Logger.LogError("Score.Save", e); } </code></pre> <p><strong>My helper class:</strong></p> <pre><code> public class GameHighScore { public List&lt;HighScoreStruct&lt;string, int&gt;&gt; highScoreList; private HighScoreStruct&lt;string, int&gt; scoreListHelper; [XmlType(TypeName = "HighScore")] public struct HighScoreStruct&lt;K, V&gt; { public K Initials { get; set; } public V Score { get; set; } public HighScoreStruct(K initials, V score) : this() { Initials = initials; Score = score; } } public GameHighScore() { highScoreList = new List&lt;HighScoreStruct&lt;string, int&gt;&gt;(); scoreListHelper = new HighScoreStruct&lt;string, int&gt;(); } public void CreateGameHighScore(List&lt;KeyValuePair&lt;string, int&gt;&gt; scoreList) { for (int i = 0; i &lt; scoreList.Count; i++) { scoreListHelper = new HighScoreStruct&lt;string, int&gt;(scoreList[i].Key, scoreList[i].Value); highScoreList.Add(scoreListHelper); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload