Skip to content

Commit

Permalink
Use 'out var'.
Browse files Browse the repository at this point in the history
  • Loading branch information
huoyaoyuan committed Nov 12, 2019
1 parent 0d81b96 commit 31cc0d1
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ csharp_style_unused_value_expression_statement_preference = discard_variable:sil
csharp_style_unused_value_assignment_preference = discard_variable:suggestion

#Style - variable declaration
csharp_style_inlined_variable_declaration = true:silent
csharp_style_inlined_variable_declaration = true:warning
csharp_style_deconstructed_variable_declaration = true:warning

#Style - other C# 7.x features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ private Pattern generateRandomPatternWithMirrored(double centreProbability, doub

var pattern = new Pattern();

bool addToCentre;
int noteCount = getRandomNoteCountMirrored(centreProbability, p2, p3, out addToCentre);
int noteCount = getRandomNoteCountMirrored(centreProbability, p2, p3, out var addToCentre);

int columnLimit = (TotalColumns % 2 == 0 ? TotalColumns : TotalColumns - 1) / 2;
int nextColumn = GetRandomColumn(upperBound: columnLimit);
Expand Down
4 changes: 1 addition & 3 deletions osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ private void load(RulesetStore rulesets)
beatmapId.Value = Model.ID.ToString();
beatmapId.BindValueChanged(idString =>
{
int parsed;

int.TryParse(idString.NewValue, out parsed);
int.TryParse(idString.NewValue, out var parsed);

Model.ID = parsed;

Expand Down
4 changes: 1 addition & 3 deletions osu.Game.Tournament/Screens/Editors/TeamEditorScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,7 @@ private void load()
userId.Value = user.Id.ToString();
userId.BindValueChanged(idString =>
{
long parsed;

long.TryParse(idString.NewValue, out parsed);
long.TryParse(idString.NewValue, out var parsed);

user.Id = parsed;

Expand Down
4 changes: 1 addition & 3 deletions osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ private void handleEvent(string line)
{
string[] split = line.Split(',');

EventType type;

if (!Enum.TryParse(split[0], out type))
if (!Enum.TryParse(split[0], out EventType type))
throw new InvalidDataException($@"Unknown event type: {split[0]}");

switch (type)
Expand Down
4 changes: 1 addition & 3 deletions osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ private void handleEvents(string line)
{
storyboardSprite = null;

EventType type;

if (!Enum.TryParse(split[0], out type))
if (!Enum.TryParse(split[0], out EventType type))
throw new InvalidDataException($@"Unknown event type: {split[0]}");

switch (type)
Expand Down
4 changes: 1 addition & 3 deletions osu.Game/IO/Legacy/SerializationReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ public sealed class VersionConfigToNamespaceAssemblyObjectBinder : Serialization

public override Type BindToType(string assemblyName, string typeName)
{
Type typeToDeserialize;

if (cache.TryGetValue(assemblyName + typeName, out typeToDeserialize))
if (cache.TryGetValue(assemblyName + typeName, out var typeToDeserialize))
return typeToDeserialize;

List<Type> tmpTypes = new List<Type>();
Expand Down
3 changes: 1 addition & 2 deletions osu.Game/Rulesets/Objects/Legacy/ConvertHitObjectParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ public override HitObject Parse(string text)
if (i >= adds.Length)
break;

int sound;
int.TryParse(adds[i], out sound);
int.TryParse(adds[i], out var sound);
nodeSoundTypes[i] = (LegacySoundType)sound;
}
}
Expand Down
3 changes: 1 addition & 2 deletions osu.Game/Storyboards/Storyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public Storyboard()

public StoryboardLayer GetLayer(string name)
{
StoryboardLayer layer;
if (!layers.TryGetValue(name, out layer))
if (!layers.TryGetValue(name, out var layer))
layers[name] = layer = new StoryboardLayer(name, layers.Values.Min(l => l.Depth) - 1);

return layer;
Expand Down

0 comments on commit 31cc0d1

Please sign in to comment.