Skip to content

Commit 8d24450

Browse files
authored
Merge pull request #1 from bmenees/utc
Improved SFTP file UTC time handling
2 parents 7691cb0 + 6771c21 commit 8d24450

8 files changed

+204
-27
lines changed

.editorconfig

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# http://EditorConfig.org
2+
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
3+
4+
# top-most EditorConfig file
5+
root = true
6+
7+
# Code files
8+
[*.{cs,csx,scs,sql,vb,vbx}]
9+
indent_size = 4
10+
indent_style = space
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
# Xml and Json files
15+
[*.{xml,xsd,csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct,json}]
16+
indent_size = 2
17+
indent_style = space
18+
insert_final_newline = true
19+
trim_trailing_whitespace = true
20+
21+
# Dotnet code style settings:
22+
[*.{cs,scs,vb}]
23+
# Sort using and Import directives with System.* appearing first
24+
dotnet_sort_system_directives_first = true
25+
26+
# Use language keywords instead of framework type names for type references
27+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
28+
dotnet_style_predefined_type_for_member_access = true:suggestion
29+
30+
# Suggest more modern language features when available
31+
dotnet_style_object_initializer = true:none
32+
dotnet_style_collection_initializer = true:none
33+
dotnet_style_coalesce_expression = true:suggestion
34+
dotnet_style_null_propagation = true:suggestion
35+
dotnet_style_explicit_tuple_names = true:suggestion
36+
37+
# CSharp code style settings:
38+
[*.{cs,scs}]
39+
# Never prefer "var"
40+
csharp_style_var_for_built_in_types = false:none
41+
csharp_style_var_when_type_is_apparent = false:none
42+
csharp_style_var_elsewhere = false:none
43+
44+
# Prefer method-like constructs to have an expression-body
45+
csharp_style_expression_bodied_methods = true:none
46+
csharp_style_expression_bodied_constructors = true:none
47+
csharp_style_expression_bodied_operators = true:none
48+
49+
# Prefer property-like constructs to have an expression-body
50+
csharp_style_expression_bodied_properties = true:none
51+
csharp_style_expression_bodied_indexers = true:none
52+
csharp_style_expression_bodied_accessors = true:none
53+
54+
# Suggest more modern language features when available
55+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
56+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
57+
csharp_style_inlined_variable_declaration = true:suggestion
58+
csharp_style_throw_expression = true:suggestion
59+
csharp_style_conditional_delegate_call = true:suggestion
60+
61+
# Newline settings
62+
csharp_new_line_before_open_brace = all
63+
csharp_new_line_before_else = true
64+
csharp_new_line_before_catch = true
65+
csharp_new_line_before_finally = true
66+
csharp_new_line_before_members_in_object_initializers = true
67+
csharp_new_line_before_members_in_anonymous_types = true
68+
69+
# Indentation preferences
70+
csharp_indent_block_contents = true
71+
csharp_indent_braces = false
72+
csharp_indent_case_contents = true
73+
csharp_indent_switch_labels = true
74+
csharp_indent_labels = flush_left
75+
76+
# Space preferences
77+
csharp_space_after_cast = false
78+
csharp_space_after_colon_in_inheritance_clause = true
79+
csharp_space_after_comma = true
80+
csharp_space_after_dot = false
81+
csharp_space_after_keywords_in_control_flow_statements = true
82+
csharp_space_after_semicolon_in_for_statement = true
83+
csharp_space_around_binary_operators = before_and_after
84+
csharp_space_around_declaration_statements = do_not_ignore
85+
csharp_space_before_colon_in_inheritance_clause = true
86+
csharp_space_before_comma = false
87+
csharp_space_before_dot = false
88+
csharp_space_before_open_square_brackets = false
89+
csharp_space_before_semicolon_in_for_statement = false
90+
csharp_space_between_empty_square_brackets = false
91+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
92+
csharp_space_between_method_call_name_and_opening_parenthesis = false
93+
csharp_space_between_method_call_parameter_list_parentheses = false
94+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
95+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
96+
csharp_space_between_method_declaration_parameter_list_parentheses = false
97+
csharp_space_between_parentheses = false
98+
csharp_space_between_square_brackets = false

src/Renci.SshNet.Tests/Classes/BaseClientTest_Disconnected_KeepAliveInterval_NotNegativeOne.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public class BaseClientTest_Disconnected_KeepAliveInterval_NotNegativeOne
1414
private BaseClient _client;
1515
private ConnectionInfo _connectionInfo;
1616
private TimeSpan _keepAliveInterval;
17-
private int _keepAliveCount;
1817

1918
[TestInitialize]
2019
public void Setup()
@@ -38,7 +37,6 @@ private void SetupData()
3837
{
3938
_connectionInfo = new ConnectionInfo("host", "user", new PasswordAuthenticationMethod("user", "pwd"));
4039
_keepAliveInterval = TimeSpan.FromMilliseconds(50d);
41-
_keepAliveCount = 0;
4240
}
4341

4442
private void CreateMocks()

src/Renci.SshNet.Tests/Classes/ClientAuthenticationTest_Success_MultiList_PartialSuccessLimitReachedFollowedBySuccessInAlternateBranch.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public class ClientAuthenticationTest_Success_MultiList_PartialSuccessLimitReach
3535
{
3636
private int _partialSuccessLimit;
3737
private ClientAuthentication _clientAuthentication;
38-
private SshAuthenticationException _actualException;
3938

4039
protected override void SetupData()
4140
{
@@ -182,4 +181,4 @@ public void AuthenticateOnPublicKeyAuthenticationMethodShouldHaveBeenInvokedTwic
182181
PublicKeyAuthenticationMethodMock.Verify(p => p.Authenticate(SessionMock.Object), Times.Exactly(2));
183182
}
184183
}
185-
}
184+
}

src/Renci.SshNet.Tests/Classes/Common/BigIntegerTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,10 +1506,12 @@ public void DefaultCtorWorks()
15061506
Assert.AreEqual("0", a.ToString(), "#4");
15071507

15081508
a = new BigInteger();
1509+
#pragma warning disable CS1718 // Comparison made to same variable
15091510
Assert.AreEqual(true, a == a, "#5");
15101511

15111512
a = new BigInteger();
15121513
Assert.AreEqual(false, a < a, "#6");
1514+
#pragma warning restore CS1718 // Comparison made to same variable
15131515

15141516
a = new BigInteger();
15151517
Assert.AreEqual(true, a < 10L, "#7");

src/Renci.SshNet.Tests/Classes/Messages/Connection/ChannelExtendedDataMessageTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void ChannelExtendedDataMessageConstructorTest()
3030
[Ignore] // placeholder
3131
public void ChannelExtendedDataMessageConstructorTest1()
3232
{
33-
uint localChannelNumber = 0; // TODO: Initialize to an appropriate value
33+
//uint localChannelNumber = 0; // TODO: Initialize to an appropriate value
3434
//ChannelExtendedDataMessage target = new ChannelExtendedDataMessage(localChannelNumber, null, null);
3535
Assert.Inconclusive("TODO: Implement code to verify target");
3636
}

src/Renci.SshNet.Tests/Classes/SftpClientTest.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,9 @@ public void SetLastAccessTimeTest()
942942
SftpClient target = new SftpClient(connectionInfo); // TODO: Initialize to an appropriate value
943943
string path = string.Empty; // TODO: Initialize to an appropriate value
944944
DateTime lastAccessTime = new DateTime(); // TODO: Initialize to an appropriate value
945+
#pragma warning disable CS0618 // Type or member is obsolete
945946
target.SetLastAccessTime(path, lastAccessTime);
947+
#pragma warning restore CS0618 // Type or member is obsolete
946948
Assert.Inconclusive("A method that does not return a value cannot be verified.");
947949
}
948950

@@ -957,7 +959,9 @@ public void SetLastAccessTimeUtcTest()
957959
SftpClient target = new SftpClient(connectionInfo); // TODO: Initialize to an appropriate value
958960
string path = string.Empty; // TODO: Initialize to an appropriate value
959961
DateTime lastAccessTimeUtc = new DateTime(); // TODO: Initialize to an appropriate value
962+
#pragma warning disable CS0618 // Type or member is obsolete
960963
target.SetLastAccessTimeUtc(path, lastAccessTimeUtc);
964+
#pragma warning restore CS0618 // Type or member is obsolete
961965
Assert.Inconclusive("A method that does not return a value cannot be verified.");
962966
}
963967

@@ -972,7 +976,9 @@ public void SetLastWriteTimeTest()
972976
SftpClient target = new SftpClient(connectionInfo); // TODO: Initialize to an appropriate value
973977
string path = string.Empty; // TODO: Initialize to an appropriate value
974978
DateTime lastWriteTime = new DateTime(); // TODO: Initialize to an appropriate value
979+
#pragma warning disable CS0618 // Type or member is obsolete
975980
target.SetLastWriteTime(path, lastWriteTime);
981+
#pragma warning restore CS0618 // Type or member is obsolete
976982
Assert.Inconclusive("A method that does not return a value cannot be verified.");
977983
}
978984

@@ -987,7 +993,9 @@ public void SetLastWriteTimeUtcTest()
987993
SftpClient target = new SftpClient(connectionInfo); // TODO: Initialize to an appropriate value
988994
string path = string.Empty; // TODO: Initialize to an appropriate value
989995
DateTime lastWriteTimeUtc = new DateTime(); // TODO: Initialize to an appropriate value
996+
#pragma warning disable CS0618 // Type or member is obsolete
990997
target.SetLastWriteTimeUtc(path, lastWriteTimeUtc);
998+
#pragma warning restore CS0618 // Type or member is obsolete
991999
Assert.Inconclusive("A method that does not return a value cannot be verified.");
9921000
}
9931001

@@ -1269,4 +1277,4 @@ private class TestInfo
12691277
public SftpDownloadAsyncResult DownloadResult { get; set; }
12701278
}
12711279
}
1272-
}
1280+
}

src/Renci.SshNet/Sftp/SftpFile.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ public DateTime LastAccessTimeUtc
9999
{
100100
get
101101
{
102-
return Attributes.LastAccessTime.ToUniversalTime();
102+
return Attributes.LastAccessTimeUtc;
103103
}
104104
set
105105
{
106-
Attributes.LastAccessTime = value.ToLocalTime();
106+
Attributes.LastAccessTimeUtc = value;
107107
}
108108
}
109109

@@ -117,11 +117,11 @@ public DateTime LastWriteTimeUtc
117117
{
118118
get
119119
{
120-
return Attributes.LastWriteTime.ToUniversalTime();
120+
return Attributes.LastWriteTimeUtc;
121121
}
122122
set
123123
{
124-
Attributes.LastWriteTime = value.ToLocalTime();
124+
Attributes.LastWriteTimeUtc = value;
125125
}
126126
}
127127

0 commit comments

Comments
 (0)