Skip to content

Commit fc38822

Browse files
committed
Fix warnings
1 parent b61cdfd commit fc38822

11 files changed

Lines changed: 114 additions & 114 deletions

TryCSharp.Samples/Linq/LinqSamples01.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void Execute()
1616
var persons = CreateSampleData();
1717

1818
var query = from person in persons
19-
where int.Parse(person.Id) >= 2
19+
where int.Parse(person.Id!) >= 2
2020
select person;
2121

2222
try
@@ -93,24 +93,24 @@ private IEnumerable<Person> CreateSampleData()
9393

9494
private class Person
9595
{
96-
public string Id { get; set; }
96+
public string? Id { get; set; }
9797

98-
public string Name { get; set; }
98+
public string? Name { get; set; }
9999

100-
public AddressInfo Address { get; set; }
100+
public AddressInfo? Address { get; set; }
101101
}
102102

103103
private class AddressInfo
104104
{
105-
public string PostCode { get; set; }
105+
public string? PostCode { get; set; }
106106

107-
public string Prefecture { get; set; }
107+
public string? Prefecture { get; set; }
108108

109-
public string Municipality { get; set; }
109+
public string? Municipality { get; set; }
110110

111-
public string HouseNumber { get; set; }
111+
public string? HouseNumber { get; set; }
112112

113-
public string Tel { get; set; }
113+
public string? Tel { get; set; }
114114
}
115115
}
116116
}

TryCSharp.Samples/Linq/LinqSamples02.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void Execute()
3232
// 複数のfrom.
3333
//
3434
var query2 = from person in persons
35-
from tel in person.Address.Tel
35+
from tel in person.Address!.Tel!
3636
select new
3737
{
3838
person.Id,
@@ -123,26 +123,26 @@ private IEnumerable<Person> CreateSampleData()
123123

124124
private class Person
125125
{
126-
public string Id { get; set; }
126+
public string? Id { get; set; }
127127

128-
public string Name { get; set; }
128+
public string? Name { get; set; }
129129

130-
public AddressInfo Address { get; set; }
130+
public AddressInfo? Address { get; set; }
131131
}
132132

133133
private class AddressInfo
134134
{
135-
public string PostCode { get; set; }
135+
public string? PostCode { get; set; }
136136

137-
public string Prefecture { get; set; }
137+
public string? Prefecture { get; set; }
138138

139-
public string Municipality { get; set; }
139+
public string? Municipality { get; set; }
140140

141-
public string HouseNumber { get; set; }
141+
public string? HouseNumber { get; set; }
142142

143-
public string[] Tel { get; set; }
143+
public string[]? Tel { get; set; }
144144

145-
public string[] Frends { get; set; }
145+
public string[]? Frends { get; set; }
146146
}
147147
}
148148
}

TryCSharp.Samples/Linq/LinqSamples03.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,26 @@ private IEnumerable<Person> CreateSampleData()
105105

106106
private class Person
107107
{
108-
public string Id { get; set; }
108+
public string? Id { get; set; }
109109

110-
public string Name { get; set; }
110+
public string? Name { get; set; }
111111

112-
public AddressInfo Address { get; set; }
112+
public AddressInfo? Address { get; set; }
113113
}
114114

115115
private class AddressInfo
116116
{
117-
public string PostCode { get; set; }
117+
public string? PostCode { get; set; }
118118

119-
public string Prefecture { get; set; }
119+
public string? Prefecture { get; set; }
120120

121-
public string Municipality { get; set; }
121+
public string? Municipality { get; set; }
122122

123-
public string HouseNumber { get; set; }
123+
public string? HouseNumber { get; set; }
124124

125-
public string[] Tel { get; set; }
125+
public string[]? Tel { get; set; }
126126

127-
public string[] Frends { get; set; }
127+
public string[]? Frends { get; set; }
128128
}
129129
}
130130
}

TryCSharp.Samples/Linq/LinqSamples04.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void Execute()
1818
// 普通に絞り込み.
1919
//
2020
var query1 = from person in persons
21-
where person.Name.EndsWith("4")
21+
where person.Name!.EndsWith("4")
2222
select person;
2323

2424
foreach (var person in query1)
@@ -30,7 +30,7 @@ where person.Name.EndsWith("4")
3030
// 複数の条件.
3131
//
3232
var query2 = from person in persons
33-
where person.Name.EndsWith("4") || (person.Address.Prefecture == "京都府")
33+
where person.Name!.EndsWith("4") || (person.Address!.Prefecture == "京都府")
3434
select person;
3535

3636
foreach (var person in query2)
@@ -42,8 +42,8 @@ where person.Name.EndsWith("4") || (person.Address.Prefecture == "京都府")
4242
// 複数のwhereを指定
4343
//
4444
var query3 = from person in persons
45-
where person.Name.Contains("gsf")
46-
where person.Address.Prefecture == "京都府"
45+
where person.Name!.Contains("gsf")
46+
where person.Address!.Prefecture == "京都府"
4747
select person;
4848

4949
foreach (var person in query3)
@@ -117,26 +117,26 @@ private IEnumerable<Person> CreateSampleData()
117117

118118
private class Person
119119
{
120-
public string Id { get; set; }
120+
public string? Id { get; set; }
121121

122-
public string Name { get; set; }
122+
public string? Name { get; set; }
123123

124-
public AddressInfo Address { get; set; }
124+
public AddressInfo? Address { get; set; }
125125
}
126126

127127
private class AddressInfo
128128
{
129-
public string PostCode { get; set; }
129+
public string? PostCode { get; set; }
130130

131-
public string Prefecture { get; set; }
131+
public string? Prefecture { get; set; }
132132

133-
public string Municipality { get; set; }
133+
public string? Municipality { get; set; }
134134

135-
public string HouseNumber { get; set; }
135+
public string? HouseNumber { get; set; }
136136

137-
public string[] Tel { get; set; }
137+
public string[]? Tel { get; set; }
138138

139-
public string[] Frends { get; set; }
139+
public string[]? Frends { get; set; }
140140
}
141141
}
142142
}

TryCSharp.Samples/Linq/LinqSamples05.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,28 +132,28 @@ private enum Country
132132

133133
private class Person
134134
{
135-
public string Id { get; set; }
135+
public string? Id { get; set; }
136136

137-
public string Name { get; set; }
137+
public string? Name { get; set; }
138138

139-
public AddressInfo Address { get; set; }
139+
public AddressInfo? Address { get; set; }
140140

141-
public Country Country { get; set; }
141+
public Country? Country { get; set; }
142142
}
143143

144144
private class AddressInfo
145145
{
146-
public string PostCode { get; set; }
146+
public string? PostCode { get; set; }
147147

148-
public string Prefecture { get; set; }
148+
public string? Prefecture { get; set; }
149149

150-
public string Municipality { get; set; }
150+
public string? Municipality { get; set; }
151151

152-
public string HouseNumber { get; set; }
152+
public string? HouseNumber { get; set; }
153153

154-
public string[] Tel { get; set; }
154+
public string[]? Tel { get; set; }
155155

156-
public string[] Frends { get; set; }
156+
public string[]? Frends { get; set; }
157157
}
158158
}
159159
}

TryCSharp.Samples/Linq/LinqSamples06.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void Execute()
2020
// (昇順の場合のascendingは付けても付けなくても良い)
2121
//
2222
var query1 = from person in persons
23-
orderby person.Id.ToInt() ascending
23+
orderby person.Id!.ToInt() ascending
2424
select person;
2525

2626
Output.WriteLine("============================================");
@@ -33,7 +33,7 @@ orderby person.Id.ToInt() ascending
3333
// 降順.
3434
//
3535
var query2 = from person in persons
36-
orderby person.Id.ToInt() descending
36+
orderby person.Id!.ToInt() descending
3737
select person;
3838

3939
Output.WriteLine("============================================");
@@ -46,7 +46,7 @@ orderby person.Id.ToInt() descending
4646
// 複数の条件でソート.
4747
//
4848
var query3 = from person in persons
49-
orderby person.Address.PostCode, person.Id.ToInt()
49+
orderby person.Address!.PostCode, person.Id!.ToInt()
5050
select person;
5151

5252
Output.WriteLine("============================================");
@@ -67,8 +67,8 @@ orderby person.Id.ToInt() descending
6767
// され直されてしまう。
6868
//
6969
var query4 = from person in persons
70-
orderby person.Address.PostCode
71-
orderby person.Id.ToInt()
70+
orderby person.Address!.PostCode
71+
orderby person.Id!.ToInt()
7272
select person;
7373

7474
Output.WriteLine("============================================");
@@ -155,28 +155,28 @@ private enum Country
155155

156156
private class Person
157157
{
158-
public string Id { get; set; }
158+
public string? Id { get; set; }
159159

160-
public string Name { get; set; }
160+
public string? Name { get; set; }
161161

162-
public AddressInfo Address { get; set; }
162+
public AddressInfo? Address { get; set; }
163163

164-
public Country Country { get; set; }
164+
public Country? Country { get; set; }
165165
}
166166

167167
private class AddressInfo
168168
{
169-
public string PostCode { get; set; }
169+
public string? PostCode { get; set; }
170170

171-
public string Prefecture { get; set; }
171+
public string? Prefecture { get; set; }
172172

173-
public string Municipality { get; set; }
173+
public string? Municipality { get; set; }
174174

175-
public string HouseNumber { get; set; }
175+
public string? HouseNumber { get; set; }
176176

177-
public string[] Tel { get; set; }
177+
public string[]? Tel { get; set; }
178178

179-
public string[] Frends { get; set; }
179+
public string[]? Frends { get; set; }
180180
}
181181
}
182182
}

TryCSharp.Samples/Linq/LinqSamples07.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ orderby personByAge.Key ascending
168168

169169
public class Person
170170
{
171-
public string Id { get; set; }
171+
public string? Id { get; set; }
172172

173-
public string Name { get; set; }
173+
public string? Name { get; set; }
174174

175175
public int Age { get; set; }
176176

@@ -179,20 +179,20 @@ public class Person
179179

180180
public class Team
181181
{
182-
public string Id { get; set; }
182+
public string? Id { get; set; }
183183

184-
public string Name { get; set; }
184+
public string? Name { get; set; }
185185

186-
public IEnumerable<string> Members { get; set; }
186+
public IEnumerable<string>? Members { get; set; }
187187
}
188188

189189
public class Project
190190
{
191-
public string Id { get; set; }
191+
public string? Id { get; set; }
192192

193-
public string Name { get; set; }
193+
public string? Name { get; set; }
194194

195-
public IEnumerable<string> Members { get; set; }
195+
public IEnumerable<string>? Members { get; set; }
196196

197197
public DateTime From { get; set; }
198198

TryCSharp.Samples/Linq/LinqSamples08.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ orderby personByAge.Key ascending
146146

147147
public class Person
148148
{
149-
public string Id { get; set; }
149+
public string? Id { get; set; }
150150

151-
public string Name { get; set; }
151+
public string? Name { get; set; }
152152

153153
public int Age { get; set; }
154154

@@ -157,20 +157,20 @@ public class Person
157157

158158
public class Team
159159
{
160-
public string Id { get; set; }
160+
public string? Id { get; set; }
161161

162-
public string Name { get; set; }
162+
public string? Name { get; set; }
163163

164-
public IEnumerable<string> Members { get; set; }
164+
public IEnumerable<string>? Members { get; set; }
165165
}
166166

167167
public class Project
168168
{
169-
public string Id { get; set; }
169+
public string? Id { get; set; }
170170

171-
public string Name { get; set; }
171+
public string? Name { get; set; }
172172

173-
public IEnumerable<string> Members { get; set; }
173+
public IEnumerable<string>? Members { get; set; }
174174

175175
public DateTime From { get; set; }
176176

0 commit comments

Comments
 (0)