Created
December 16, 2020 05:10
-
-
Save kyubuns/aab83e03f896fcb58a0c0ef8469bc4b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Xml.Linq; | |
using UnityEditor; | |
public class EnableNullable : AssetPostprocessor | |
{ | |
private static string OnGeneratedCSProject(string path, string content) | |
{ | |
var document = XDocument.Parse(content); | |
if (document.Root == null) throw new Exception($"document.Root == null"); | |
XNamespace xNamespace = "http://schemas.microsoft.com/developer/msbuild/2003"; | |
// ReSharper disable once PossibleNullReferenceException | |
var propertyGroup = document | |
.Element(xNamespace + "Project") | |
.Elements(xNamespace + "PropertyGroup") | |
.First(); | |
propertyGroup.Add(new XElement(xNamespace + "Nullable", "enable")); | |
return document.ToString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment