Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

Commit 772a9ce

Browse files
committed
Feedback
1 parent 830dfcd commit 772a9ce

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/Microsoft.AspNetCore.Session/DistributedSession.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public bool IsAvailable
7676
{
7777
get
7878
{
79+
Load();
7980
return _isAvailable;
8081
}
8182
}
@@ -85,7 +86,7 @@ public string Id
8586
get
8687
{
8788
Load();
88-
if (IsAvailable)
89+
if (_isAvailable)
8990
{
9091
if (_sessionId == null)
9192
{
@@ -95,7 +96,7 @@ public string Id
9596
}
9697
else
9798
{
98-
return default(string);
99+
return string.Empty;
99100
}
100101
}
101102
}
@@ -105,7 +106,7 @@ private byte[] IdBytes
105106
get
106107
{
107108
Load();
108-
if (IsAvailable)
109+
if (_isAvailable)
109110
{
110111
if (_sessionIdBytes == null)
111112
{
@@ -116,7 +117,7 @@ private byte[] IdBytes
116117
}
117118
else
118119
{
119-
return default(byte[]);
120+
return null;
120121
}
121122
}
122123
}
@@ -126,21 +127,21 @@ public IEnumerable<string> Keys
126127
get
127128
{
128129
Load();
129-
if (IsAvailable)
130+
if (_isAvailable)
130131
{
131132
return _store.Keys.Select(key => key.KeyString);
132133
}
133134
else
134135
{
135-
return default(IEnumerable<string>);
136+
return Enumerable.Empty<string>();
136137
}
137138
}
138139
}
139140

140141
public bool TryGetValue(string key, out byte[] value)
141142
{
142143
Load();
143-
if (IsAvailable)
144+
if (_isAvailable)
144145
{
145146
return _store.TryGetValue(new EncodedKey(key), out value);
146147
}
@@ -166,7 +167,7 @@ public void Set(string key, byte[] value)
166167
}
167168

168169
Load();
169-
if (IsAvailable)
170+
if (_isAvailable)
170171
{
171172
if (!_tryEstablishSession())
172173
{
@@ -182,7 +183,7 @@ public void Set(string key, byte[] value)
182183
public void Remove(string key)
183184
{
184185
Load();
185-
if (IsAvailable)
186+
if (_isAvailable)
186187
{
187188
_isModified |= _store.Remove(new EncodedKey(key));
188189
}
@@ -191,7 +192,7 @@ public void Remove(string key)
191192
public void Clear()
192193
{
193194
Load();
194-
if (IsAvailable)
195+
if (_isAvailable)
195196
{
196197
_isModified |= _store.Count > 0;
197198
_store.Clear();

test/Microsoft.AspNetCore.Session.Tests/SessionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,9 @@ public async Task SessionLogsCacheReadException()
506506
{
507507
byte[] value;
508508
Assert.False(context.Session.TryGetValue("key", out value));
509-
Assert.Equal(default(byte[]), value);
510-
Assert.Equal(default(string), context.Session.Id);
511-
Assert.Equal(default(IEnumerable<string>), context.Session.Keys);
509+
Assert.Equal(null, value);
510+
Assert.Equal(string.Empty, context.Session.Id);
511+
Assert.False(context.Session.Keys.Any());
512512
return Task.FromResult(0);
513513
});
514514
})

0 commit comments

Comments
 (0)