<div dir="ltr">I was looking through some of the mcs warnings on mono build today and some seem to be off from looking at the code<div><br></div><div><div>System.Collections.Concurrent/BlockingCollection.cs(387,4): warning CS0162: Unreachable code detected</div>
<div>System.Collections.Concurrent/BlockingCollection.cs(375,9): warning CS0219: The variable `index' is assigned but its value is never used</div><div>System.Collections.Concurrent/BlockingCollection.cs(412,4): warning CS0162: Unreachable code detected</div>
<div>System.Collections.Concurrent/BlockingCollection.cs(396,9): warning CS0219: The variable `index' is assigned but its value is never used</div><div>System.Net/WebConnectionStream.cs(695,11): warning CS0219: The variable `bytes' is assigned but its value is never used</div>
<div>System.Diagnostics/TraceImpl.cs(44,15): warning CS0649: Field `System.Diagnostics.TraceImplSettings.AutoFlush' is never assigned to, and will always have its default value `false'</div><div><br></div><div>Take the index is assigned but value never used. Here is related code from that area</div>
<div><br></div><div><div><span class="" style="white-space:pre">                </span>public static int TakeFromAny (BlockingCollection<T>[] collections, out T item)</div><div><span class="" style="white-space:pre">              </span>{</div>
<div><span class="" style="white-space:pre">                    </span>item = default (T);</div><div><span class="" style="white-space:pre">                        </span>CheckArray (collections);</div><div><span class="" style="white-space:pre">                  </span>int index = 0;</div>
<div><span class="" style="white-space:pre">                    </span>foreach (var coll in collections) {</div><div><span class="" style="white-space:pre">                                </span>try {</div><div><span class="" style="white-space:pre">                                      </span>item = coll.Take ();</div>
<div><span class="" style="white-space:pre">                                    </span>return index;</div><div><span class="" style="white-space:pre">                              </span>} catch {}</div><div><span class="" style="white-space:pre">                         </span>index++;</div><div><span class="" style="white-space:pre">                   </span>}</div>
<div><span class="" style="white-space:pre">                    </span>return -1;</div><div><span class="" style="white-space:pre">         </span>}</div><div><br></div><div><span class="" style="white-space:pre">         </span>public static int TakeFromAny (BlockingCollection<T>[] collections, out T item, CancellationToken cancellationToken)</div>
<div><span class="" style="white-space:pre">            </span>{</div><div><span class="" style="white-space:pre">                  </span>item = default (T);</div><div><span class="" style="white-space:pre">                        </span>CheckArray (collections);</div>
<div><span class="" style="white-space:pre">                    </span>int index = 0;</div><div><span class="" style="white-space:pre">                     </span>foreach (var coll in collections) {</div><div><span class="" style="white-space:pre">                                </span>try {</div>
<div><span class="" style="white-space:pre">                                    </span>item = coll.Take (cancellationToken);</div><div><span class="" style="white-space:pre">                                      </span>return index;</div><div><span class="" style="white-space:pre">                              </span>} catch {}</div>
<div><span class="" style="white-space:pre">                            </span>index++;</div><div><span class="" style="white-space:pre">                   </span>}</div><div><span class="" style="white-space:pre">                  </span>return -1;</div><div><span class="" style="white-space:pre">         </span>}</div>
<div><br></div><div><span class="" style="white-space:pre">           </span>public static int TryTakeFromAny (BlockingCollection<T>[] collections, out T item)</div><div><span class="" style="white-space:pre">           </span>{</div>
<div><span class="" style="white-space:pre">                    </span>item = default (T);</div><div><br></div><div><span class="" style="white-space:pre">                       </span>CheckArray (collections);</div><div><span class="" style="white-space:pre">                  </span>int index = 0;</div>
<div><span class="" style="white-space:pre">                    </span>foreach (var coll in collections) {</div><div><span class="" style="white-space:pre">                                </span>if (coll.TryTake (out item))</div><div><span class="" style="white-space:pre">                                       </span>return index;</div>
<div><span class="" style="white-space:pre">                            </span>index++;</div><div><span class="" style="white-space:pre">                   </span>}</div><div><span class="" style="white-space:pre">                  </span>return -1;</div><div><span class="" style="white-space:pre">         </span>}</div>
</div><div><br></div><div>Also should the line number be pointing to the actual line in the source? In this case it was pointing at a }catch{} (on the first one). I don't see how index is not being used there</div><div>
<br></div>-- <br>Le doute n'est pas une condition agréable, mais la certitude est absurde.
</div></div>