Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purge all compiler warnings #1601

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Purge all compiler warnings
The vast majority are simply the compiler being confused about the signature saying "not null" and then an immediate check if the value is null or not.  It errs on the safe side and issues warnings about a possible null value on some platforms but not others.  The compiler will let you know if you are potentially passing a null to a method that cannot accept it, and so the null checks are all less important now.

Also fill in missing doc comments and update all bad refs between doc pages (including changes to gen_defaults.py)
  • Loading branch information
borrrden committed Mar 7, 2024
commit bc5c50a6db3c670e237f73f6290e2bf96423ca43
16 changes: 16 additions & 0 deletions src/Couchbase.Lite.Shared/API/DI/IReachability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,40 @@

namespace Couchbase.Lite.DI
{
/// <summary>
/// An interface for describing whether a given URL is reachable via
/// network connection or not.
/// </summary>
public interface IReachability
{
#region Variables

/// <summary>
/// Fired when the status of connectivity changes
/// </summary>
event EventHandler<NetworkReachabilityChangeEventArgs> StatusChanged;

#endregion

#region Properties

/// <summary>
/// The URL to track connectivity to
/// </summary>
Uri? Url { get; set; }

#endregion

#region Public Methods

/// <summary>
/// Start monitoring for changes in network status
/// </summary>
void Start();

/// <summary>
/// Stop monitoring for changes in network status
/// </summary>
void Stop();

#endregion
Expand Down
1 change: 0 additions & 1 deletion src/Couchbase.Lite.Shared/API/Database/Collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,6 @@ private void PurgeDocById(string id)
private bool Save(Document document, Document? baseDocument,
ConcurrencyControl concurrencyControl, bool deletion)
{
Debug.Assert(document != null);
if (deletion && document.RevisionID == null) {
throw new CouchbaseLiteException(C4ErrorCode.NotFound,
CouchbaseLiteErrorMessage.DeleteDocFailedNotSaved);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public sealed class CollectionChangedEventArgs : DatabaseChangedEventArgs
Database database)
:base(database, documentIDs)
{
Debug.Assert(collection != null);
Collection = collection;
}

Expand Down
4 changes: 1 addition & 3 deletions src/Couchbase.Lite.Shared/API/Database/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,8 +1178,6 @@ internal bool SaveCookie(string cookie, Uri uri, bool acceptParentDomain)

internal void ResolveConflict(string docID, IConflictResolver? conflictResolver, Collection collection)
{
Debug.Assert(docID != null);

var writeSuccess = false;
while (!writeSuccess) {
var readSuccess = false;
Expand Down Expand Up @@ -1284,7 +1282,7 @@ private static string DatabasePath(string? directory)
CouchbaseLiteErrorMessage.ResolveDefaultDirectoryFailed);
}

return directoryToUse;
return directoryToUse!;
}

private static string DatabasePath(string name, string? directory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ public class DatabaseChangedEventArgs : EventArgs

internal DatabaseChangedEventArgs(Database database, IReadOnlyList<string> documentIDs)
{
Debug.Assert(database != null);
Debug.Assert(documentIDs != null);
Debug.Assert(documentIDs.All(x => x != null));
Database = database;
DocumentIDs = documentIDs;
}
Expand Down
2 changes: 0 additions & 2 deletions src/Couchbase.Lite.Shared/API/Document/Blob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,6 @@ internal bool JSONEquals(Dictionary<string, object> obj)

internal void Install(Database db)
{
Debug.Assert(db != null);

if (Digest != null && _db == null) {
_db = db;
}
Expand Down
10 changes: 3 additions & 7 deletions src/Couchbase.Lite.Shared/API/Document/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ public unsafe class Document : IDictionaryObject, IJSON, IDisposable
{
get {
Debug.Assert(Database != null && Database.c4db != null);
return Database.c4db;
return Database!.c4db;
}
}

internal C4Collection* c4Coll
{
get {
Debug.Assert(Collection != null && Collection.c4coll != null);
return Collection.c4coll;
return Collection!.c4coll;
}
}

Expand Down Expand Up @@ -165,8 +165,6 @@ public unsafe class Document : IDictionaryObject, IJSON, IDisposable

internal Document(Collection? collection, string id, C4DocumentWrapper? c4Doc)
{
Debug.Assert(id != null);

Collection = collection;
Id = id;
this.c4Doc = c4Doc;
Expand Down Expand Up @@ -196,8 +194,6 @@ internal Document(Collection? collection, string id, string revId, FLDict* body)
internal Document(Document other)
: this(other.Collection, other.Id, other.c4Doc?.Retain<C4DocumentWrapper>())
{
Debug.Assert(other != null);

if(other._root != null) {
_root = new MRoot(other._root);
} else {
Expand Down Expand Up @@ -292,7 +288,7 @@ private void UpdateDictionary()
if (Data != null) {
Debug.Assert(Database != null);
Misc.SafeSwap(ref _root,
new MRoot(new DocContext(Database, _c4Doc), (FLValue*) Data, IsMutable));
new MRoot(new DocContext(Database!, _c4Doc), (FLValue*) Data, IsMutable));
Collection?.ThreadSafety?.DoLocked(() => _dict = (DictionaryObject?) _root!.AsObject());
} else {
Misc.SafeSwap(ref _root, null);
Expand Down
2 changes: 1 addition & 1 deletion src/Couchbase.Lite.Shared/API/Document/MutableDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ internal override FLSliceResult Encode()
Debug.Assert(Database != null);

var body = new FLSliceResult();
Database.ThreadSafety.DoLocked(() =>
Database!.ThreadSafety.DoLocked(() =>
{
FLEncoder* encoder = null;
try {
Expand Down
Loading