Skip to content

Commit

Permalink
string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
BinaryConstruct committed Apr 23, 2017
1 parent 096ec05 commit afa64ef
Show file tree
Hide file tree
Showing 23 changed files with 253 additions and 93 deletions.
160 changes: 160 additions & 0 deletions TEditXna/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# editorconfig.org

# top-most EditorConfig file
root = true

# Default settings:
# A newline ending every file
# Use 4 spaces as indentation
[*]
insert_final_newline = true
indent_style = space
indent_size = 4

[project.json]
indent_size = 2

# C# files
[*.cs]
# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_within_query_expression_clauses = true

# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left

# avoid this. unless absolutely necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

# only use var when it's obvious what the variable type is
csharp_style_var_for_built_in_types = false:none
csharp_style_var_when_type_is_apparent = false:none
csharp_style_var_elsewhere = false:suggestion

# use language keywords instead of BCL types
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion

# name all constant fields using PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style

dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const

dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# static fields should have s_ prefix
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style

dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static

dotnet_naming_style.static_prefix_style.required_prefix = s_
dotnet_naming_style.static_prefix_style.capitalization = camel_case

# internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style

dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal

dotnet_naming_style.camel_case_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case

# Code style defaults
dotnet_sort_system_directives_first = true
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false

# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion

# Expression-bodied members
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none
csharp_style_expression_bodied_properties = true:none
csharp_style_expression_bodied_indexers = true:none
csharp_style_expression_bodied_accessors = true:none

# Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion

# Null checking preferences
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# Space preferences
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = do_not_ignore
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

# C++ Files
[*.{cpp,h,in}]
curly_bracket_next_line = true
indent_brace_style = Allman

# Xml project files
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
indent_size = 2

# Xml build files
[*.builds]
indent_size = 2

# Xml files
[*.{xml,stylecop,resx,ruleset}]
indent_size = 2

# Xml config files
[*.{props,targets,config,nuspec}]
indent_size = 2

# Shell scripts
[*.sh]
end_of_line = lf
[*.{cmd, bat}]
end_of_line = crlf
12 changes: 6 additions & 6 deletions TEditXna/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ static App()
protected override void OnStartup(StartupEventArgs e)
{
ErrorLogging.Initialize();
ErrorLogging.Log(string.Format("Starting TEdit {0}", ErrorLogging.Version));
ErrorLogging.Log(string.Format("OS: {0}", Environment.OSVersion));
ErrorLogging.Log($"Starting TEdit {ErrorLogging.Version}");
ErrorLogging.Log($"OS: {Environment.OSVersion}");

Assembly asm = Assembly.GetExecutingAssembly();
Version = FileVersionInfo.GetVersionInfo(asm.Location);
Expand All @@ -34,7 +34,7 @@ protected override void OnStartup(StartupEventArgs e)
int directxMajorVersion = DependencyChecker.GetDirectxMajorVersion();
if (directxMajorVersion < 11)
{
ErrorLogging.Log(string.Format("DirectX {0} unsupported. DirectX 11 or higher is required.", directxMajorVersion));
ErrorLogging.Log($"DirectX {directxMajorVersion} unsupported. DirectX 11 or higher is required.");
}
}
catch (Exception ex)
Expand Down Expand Up @@ -62,8 +62,8 @@ protected override void OnStartup(StartupEventArgs e)
}
else
{
ErrorLogging.Log(string.Format("Terraria v{0}", DependencyChecker.GetTerrariaVersion() ?? "not found"));
ErrorLogging.Log(string.Format("Terraria Data Path: {0}", DependencyChecker.PathToContent));
ErrorLogging.Log($"Terraria v{DependencyChecker.GetTerrariaVersion() ?? "not found"}");
ErrorLogging.Log($"Terraria Data Path: {DependencyChecker.PathToContent}");
}
}
catch (Exception ex)
Expand All @@ -75,7 +75,7 @@ protected override void OnStartup(StartupEventArgs e)

if (e.Args != null && e.Args.Count() > 0)
{
ErrorLogging.Log(string.Format("Command Line Open: {0}", e.Args[0]));
ErrorLogging.Log($"Command Line Open: {e.Args[0]}");
Properties["OpenFile"] = e.Args[0];
}

Expand Down
4 changes: 2 additions & 2 deletions TEditXna/DependencyChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void CheckPaths()
// if hard coded in settings.xml try that location first
if (!string.IsNullOrWhiteSpace(TEditXNA.Terraria.World.AltC))
{
if(Directory.Exists(TEditXNA.Terraria.World.AltC))
if (Directory.Exists(TEditXNA.Terraria.World.AltC))
path = TEditXNA.Terraria.World.AltC;
}

Expand Down Expand Up @@ -84,7 +84,7 @@ public static void CheckPaths()
while (!DirectoryHasContentFolder(tempPath) && retry)
{
if (MessageBox.Show(
string.Format("Directory does not appear to contain Content.\r\nPress retry to pick a new folder or cancel to use \r\n{0}\r\n as your terraria path.", path),
$"Directory does not appear to contain Content.\r\nPress retry to pick a new folder or cancel to use \r\n{path}\r\n as your terraria path.",
"Terraria Content not Found",
MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry)
{
Expand Down
17 changes: 9 additions & 8 deletions TEditXna/Editor/MouseTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,34 +69,35 @@ public Tile Tile
string frameNameKey = World.GetFrameNameKey(_tile.Type, _tile.U, _tile.V);
TileName = World.FrameNames.ContainsKey(frameNameKey) ? World.FrameNames[frameNameKey] : tileProperty.Name + "*";
}
TileName = _tile.IsActive ? string.Format("{0} ({1})", TileName, _tile.Type) : "[empty]";
TileName = _tile.IsActive ? $"{TileName} ({_tile.Type})" : "[empty]";
}
else
TileName = string.Format("INVALID TILE ({0})", _tile.Type);
TileName = $"INVALID TILE ({_tile.Type})";

if (World.WallProperties.Count > _tile.Wall)
WallName = string.Format("{0} ({1})", World.WallProperties[_tile.Wall].Name, _tile.Wall);
WallName = $"{World.WallProperties[_tile.Wall].Name} ({_tile.Wall})";
else
WallName = string.Format("INVALID WALL ({0})", _tile.Wall);
WallName = $"INVALID WALL ({_tile.Wall})";

UV = new Vector2Short(_tile.U, _tile.V);
if (_tile.LiquidAmount > 0)
{
TileExtras = string.Format("{0}: {1}", _tile.LiquidType, _tile.LiquidAmount);
TileExtras = $"{_tile.LiquidType}: {_tile.LiquidAmount}";
}
else
TileExtras = string.Empty;

if (_tile.TileColor > 0)
{
if (_tile.WallColor > 0)
Paint = string.Format("Tile: {0}, Wall: {1}", World.PaintProperties[_tile.TileColor].Name, World.PaintProperties[_tile.WallColor].Name);
Paint =
$"Tile: {World.PaintProperties[_tile.TileColor].Name}, Wall: {World.PaintProperties[_tile.WallColor].Name}";
else
Paint = string.Format("Tile: {0}", World.PaintProperties[_tile.TileColor].Name);
Paint = $"Tile: {World.PaintProperties[_tile.TileColor].Name}";
}
else if (_tile.WallColor > 0)
{
Paint = string.Format("Wall: {0}", World.PaintProperties[_tile.WallColor].Name);
Paint = $"Wall: {World.PaintProperties[_tile.WallColor].Name}";
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public FindChestWithPluginResultView(IEnumerable<Vector2> locations)
foreach (Vector2 location in locations)
{
// Was to lazy to do it with Bindings (sorry)
LocationList.Items.Add(String.Format("{0}, {1}", location.X, location.Y));
LocationList.Items.Add($"{location.X}, {location.Y}");
}
}

Expand Down
8 changes: 4 additions & 4 deletions TEditXna/Editor/Undo/UndoManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static UndoManager()

if (!Directory.Exists(Dir))
{
ErrorLogging.Log(string.Format("Creating Undo cache: {0}", Dir));
ErrorLogging.Log($"Creating Undo cache: {Dir}");

Directory.CreateDirectory(Dir);
File.Create(UndoAliveFile).Close();
Expand Down Expand Up @@ -66,22 +66,22 @@ private static void CleanupOldUndoFiles(bool forceCleanup = false)
{
foreach (var file in Directory.GetFiles(WorldViewModel.TempPath).ToList())
{
ErrorLogging.Log(string.Format("Removing old undo file: {0}", file));
ErrorLogging.Log($"Removing old undo file: {file}");
File.Delete(file);
}

foreach (var dir in Directory.GetDirectories(WorldViewModel.TempPath).ToList())
{
if (!Equals(dir, Dir) && !IsUndoDirAlive(dir))
{
ErrorLogging.Log(string.Format("Removing old undo cache: {0}", dir));
ErrorLogging.Log($"Removing old undo cache: {dir}");
Directory.Delete(dir, true);
}
}

if (forceCleanup)
{
ErrorLogging.Log(string.Format("Removing undo cache: {0}", Dir));
ErrorLogging.Log($"Removing undo cache: {Dir}");
Directory.Delete(Dir, true);
}
}
Expand Down
7 changes: 2 additions & 5 deletions TEditXna/ErrorLogging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ public static void Log(string message)
lock (LogFilePath)
{
File.AppendAllText(LogFilePath,
string.Format("{0}: {1} {2}",
DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss"),
message,
Environment.NewLine));
$"{DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss")}: {message} {Environment.NewLine}");
}
}

Expand All @@ -78,7 +75,7 @@ public static void LogException(object ex)
if (e.InnerException != null)
LogException(e.InnerException);

Log(String.Format("{0} - {1}\r\n{2}", ErrorLevel.Error, e.Message, e.StackTrace));
Log($"{ErrorLevel.Error} - {e.Message}\r\n{e.StackTrace}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion TEditXna/Geometry/Fill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static IEnumerable<Vector2Int32> FillEllipse(Vector2Int32 offset, Vector2
var center = new Vector2Int32(xc, yc);
var radius = new Vector2Int32(xr, yr);

Debug.WriteLine(string.Format("Center: {0}, Radius: {1}", center, radius));
Debug.WriteLine($"Center: {center}, Radius: {radius}");

return FillEllipseCentered(center, radius);
}
Expand Down
Loading

0 comments on commit afa64ef

Please sign in to comment.