Skip to content

Commit

Permalink
feat: add nullable option
Browse files Browse the repository at this point in the history
close #5
  • Loading branch information
mob-sakai committed Oct 22, 2020
1 parent be11bae commit 9bc0b85
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Editor/CSharpProjectModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ private static string OnGeneratedCSProject(string path, string content)
if (!setting.UseDefaultCompiler)
content = Regex.Replace(content, "<LangVersion>.*</LangVersion>", "<LangVersion>" + setting.LanguageVersion + "</LangVersion>", RegexOptions.Multiline);

// Enable nullable.
if (setting.EnableNullable)
content = Regex.Replace(content, "(\\s+)(<LangVersion>.*</LangVersion>)([\r\n]+)", "$1$2$3$1<Nullable>enable</Nullable>$3");

return content;
}
}
Expand Down
1 change: 1 addition & 0 deletions Editor/CscSettingsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private static void OnGUI(string searchContext)
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_PackageName"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_PackageVersion"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_LanguageVersion"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EnableNullable"));
EditorGUI.indentLevel--;
}

Expand Down
1 change: 1 addition & 0 deletions Editor/InspectorGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ private static void OnPostHeaderGUI(Editor editor)
EditorGUILayout.PropertyField(_serializedObject.FindProperty("m_PackageName"));
EditorGUILayout.PropertyField(_serializedObject.FindProperty("m_PackageVersion"));
EditorGUILayout.PropertyField(_serializedObject.FindProperty("m_LanguageVersion"));
EditorGUILayout.PropertyField(_serializedObject.FindProperty("m_EnableNullable"));
EditorGUI.indentLevel--;
}

Expand Down

0 comments on commit 9bc0b85

Please sign in to comment.