UnityEssentials
Small but useful tools and features for Unity
SuppressionOfWarningCS0649.cs
Go to the documentation of this file.
1 using System.IO;
2 using UnityEditor;
3 using UnityEngine;
4 #if UNITY_EDITOR
5 namespace Essentials.EssentialsSettings.UnityConfigurationModifications
6 {
7 
8  public class SuppressionOfWarningCS0649 : Adjustment
9  {
13  public override void Apply()
14  {
15  File.WriteAllText("Assets/csc.rsp", "#\"This file disables the warning 'CS0649: Field 'var' is never assigned to, and will always have its default value null.'\"\n-nowarn:0649");
16  AssetDatabase.Refresh();
17 
18  Debug.Log("Warning CS0649 disabled.");
19  }
20 
24  public override void Revert()
25  {
26  File.Delete("Assets/csc.rsp.meta");
27  File.Delete("Assets/csc.rsp");
28  AssetDatabase.Refresh();
29 
30  Debug.Log("Warning CS0649 enabled.");
31  }
32 
33  public override string title { get => "Disable warning CS0649"; }
34  public override string revertButtonText { get => "Revert"; }
35  public override string infoURL { get => "https://answers.unity.com/questions/60461/warning-cs0649-field-is-never-assigned-to-and-will.html"; }
36  public override string applyButtonText { get => "Apply"; }
37 
38  public override string applyAdjustmentShortExplanation { get => "Disable the warning CS069 creating a file named csc.rsp in the project folder."; }
39  public override string revertAdjustmentShortExplanation { get => "Enable the warning CS069 by removing a file named csc.rsp in the project folder."; }
40 
41  public override bool showInSettingsWindow => false;
42  }
43 
44 }
45 #endif