Skip to content

Commit

Permalink
Enabling NRTs
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Sep 18, 2022
1 parent 8acaaf0 commit cfc66ad
Show file tree
Hide file tree
Showing 129 changed files with 824 additions and 514 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,16 @@ csharp_using_directive_placement = outside_namespace:error
[*.cs]
dotnet_diagnostic.CA1401.severity = silent
dotnet_diagnostic.SYSLIB1054.severity = silent

###############################################################################
# Set dotnet analyzer rules to:
# disable various SYSLIB analyzers
# due to unexpected exceptions thrown in the IDE
###############################################################################
[*.cs]
dotnet_diagnostic.SYSLIB1055.severity = silent
dotnet_diagnostic.SYSLIB1056.severity = silent
dotnet_diagnostic.SYSLIB1057.severity = silent
dotnet_diagnostic.SYSLIB1058.severity = silent
dotnet_diagnostic.SYSLIB1060.severity = silent
dotnet_diagnostic.SYSLIB1061.severity = silent
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<DebugType>embedded</DebugType>
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<!-- <Nullable>enable</Nullable> -->
<Nullable>enable</Nullable>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<SignAssembly>true</SignAssembly>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<!-- Settings that append the existing setting value -->
<PropertyGroup>
<NoWarn>$(NoWarn)</NoWarn>
<NoWarn>$(NoWarn);AD0001</NoWarn>
</PropertyGroup>

<!-- Settings that are only set for CI builds -->
Expand Down
1 change: 1 addition & 0 deletions sources/ClangSharp.Interop/ClangSharp.Interop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<Compile Remove="Shims/MemberNotNullWhenAttribute.cs" />
<Compile Remove="Shims/SkipLocalsInitAttribute.cs" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXClientData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public CXClientData(IntPtr handle)

public static bool operator !=(CXClientData left, CXClientData right) => left.Handle != right.Handle;

public override bool Equals(object obj) => (obj is CXClientData other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXClientData other) && Equals(other);

public bool Equals(CXClientData other) => this == other;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXCompilationDatabase other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXCompilationDatabase other) && Equals(other);

public bool Equals(CXCompilationDatabase other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public CXCompileCommand(IntPtr handle)

public static bool operator !=(CXCompileCommand left, CXCompileCommand right) => left.Handle != right.Handle;

public override bool Equals(object obj) => (obj is CXCompileCommand other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXCompileCommand other) && Equals(other);

public bool Equals(CXCompileCommand other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXCompileCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXCompileCommands other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXCompileCommands other) && Equals(other);

public bool Equals(CXCompileCommands other) => this == other;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public CXCompletionString(IntPtr handle)

public static bool operator !=(CXCompletionString left, CXCompletionString right) => left.Handle != right.Handle;

public override bool Equals(object obj) => (obj is CXCompletionString other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXCompletionString other) && Equals(other);

public bool Equals(CXCompletionString other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@ public static void DisposeOverriddenCursors(ReadOnlySpan<CXCursor> overridden)
}
}

public override bool Equals(object obj) => (obj is CXCursor other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXCursor other) && Equals(other);

public bool Equals(CXCursor other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXCursorSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXCursorSet other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXCursorSet other) && Equals(other);

public bool Equals(CXCursorSet other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXDiagnostic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXDiagnostic other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXDiagnostic other) && Equals(other);

public bool Equals(CXDiagnostic other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXDiagnosticSet other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXDiagnosticSet other) && Equals(other);

public bool Equals(CXDiagnosticSet other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXEvalResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXEvalResult other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXEvalResult other) && Equals(other);

public bool Equals(CXEvalResult other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public CXFile(IntPtr handle)

public static bool operator !=(CXFile left, CXFile right) => clang.File_isEqual(left, right) == 0;

public override bool Equals(object obj) => (obj is CXFile other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXFile other) && Equals(other);

public bool Equals(CXFile other) => this == other;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public CXIdxClientASTFile(IntPtr handle)

public static bool operator !=(CXIdxClientASTFile left, CXIdxClientASTFile right) => left.Handle != right.Handle;

public override bool Equals(object obj) => (obj is CXIdxClientASTFile other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXIdxClientASTFile other) && Equals(other);

public bool Equals(CXIdxClientASTFile other) => this == other;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public CXIdxClientContainer(IntPtr handle)

public static bool operator !=(CXIdxClientContainer left, CXIdxClientContainer right) => left.Handle != right.Handle;

public override bool Equals(object obj) => (obj is CXIdxClientContainer other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXIdxClientContainer other) && Equals(other);

public bool Equals(CXIdxClientContainer other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public CXIdxClientEntity(IntPtr handle)

public static bool operator !=(CXIdxClientEntity left, CXIdxClientEntity right) => left.Handle != right.Handle;

public override bool Equals(object obj) => (obj is CXIdxClientEntity other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXIdxClientEntity other) && Equals(other);

public bool Equals(CXIdxClientEntity other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public CXIdxClientFile(IntPtr handle)

public static bool operator !=(CXIdxClientFile left, CXIdxClientFile right) => left.Handle != right.Handle;

public override bool Equals(object obj) => (obj is CXIdxClientFile other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXIdxClientFile other) && Equals(other);

public bool Equals(CXIdxClientFile other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public CXGlobalOptFlags GlobalOptions

public void Dispose() => clang.disposeIndex(this);

public override bool Equals(object obj) => (obj is CXIndex other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXIndex other) && Equals(other);

public bool Equals(CXIndex other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXIndexAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXIndexAction other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXIndexAction other) && Equals(other);

public bool Equals(CXIndexAction other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public CXModule(IntPtr handle)

public static bool operator !=(CXModule left, CXModule right) => left.Handle != right.Handle;

public override bool Equals(object obj) => (obj is CXModule other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXModule other) && Equals(other);

public bool Equals(CXModule other) => this == other;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXModuleMapDescriptor other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXModuleMapDescriptor other) && Equals(other);

public bool Equals(CXModuleMapDescriptor other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXPrintingPolicy other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXPrintingPolicy other) && Equals(other);

public bool Equals(CXPrintingPolicy other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXRemapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXRemapping other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXRemapping other) && Equals(other);

public bool Equals(CXRemapping other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXSourceLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public unsafe partial struct CXSourceLocation : IEquatable<CXSourceLocation>

public static bool operator !=(CXSourceLocation left, CXSourceLocation right) => clang.equalLocations(left, right) == 0;

public override bool Equals(object obj) => (obj is CXSourceLocation other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXSourceLocation other) && Equals(other);

public bool Equals(CXSourceLocation other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXSourceRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public partial struct CXSourceRange : IEquatable<CXSourceRange>

public static CXSourceRange Create(CXSourceLocation begin, CXSourceLocation end) => clang.getRange(begin, end);

public override bool Equals(object obj) => (obj is CXSourceRange other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXSourceRange other) && Equals(other);

public bool Equals(CXSourceRange other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXTargetInfo other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXTargetInfo other) && Equals(other);

public bool Equals(CXTargetInfo other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public unsafe partial struct CXToken : IEquatable<CXToken>
(left.ptr_data != right.ptr_data);
}

public override bool Equals(object obj) => (obj is CXSourceRange other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXSourceRange other) && Equals(other);

public bool Equals(CXToken other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void DisposeTokens(ReadOnlySpan<CXToken> tokens)
}
}

public override bool Equals(object obj) => (obj is CXTranslationUnit other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXTranslationUnit other) && Equals(other);

public bool Equals(CXTranslationUnit other) => this == other;

Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Extensions/CXType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public string TypeClassSpelling

public static bool operator !=(CXType left, CXType right) => clang.equalTypes(left, right) == 0;

public override bool Equals(object obj) => (obj is CXType other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXType other) && Equals(other);

public bool Equals(CXType other) => this == other;

Expand Down
4 changes: 2 additions & 2 deletions sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public CXVirtualFileOverlay(IntPtr handle)

public static CXVirtualFileOverlay Create(uint options) => clang.VirtualFileOverlay_create(options);

public CXErrorCode AddFileMapping(string virtualPath, string realPath)
public CXErrorCode AddFileMapping(string? virtualPath, string? realPath)
{
using var marshaledVirtualPath = new MarshaledString(virtualPath);
using var marshaledRealPath = new MarshaledString(realPath);
Expand All @@ -39,7 +39,7 @@ public void Dispose()
}
}

public override bool Equals(object obj) => (obj is CXVirtualFileOverlay other) && Equals(other);
public override bool Equals(object? obj) => (obj is CXVirtualFileOverlay other) && Equals(other);

public bool Equals(CXVirtualFileOverlay other) => this == other;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace ClangSharp.Interop;

public static unsafe partial class @clang
{
public static event DllImportResolver ResolveLibrary;
public static event DllImportResolver? ResolveLibrary;

static @clang()
{
Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/Internals/MarshaledString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ClangSharp.Interop;

public unsafe struct MarshaledString : IDisposable
{
public MarshaledString(string input)
public MarshaledString(string? input)
{
int length;
IntPtr value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ClangSharp.Interop;

public unsafe ref struct MarshaledStringArray
{
private MarshaledString[] _values;
private MarshaledString[]? _values;

public MarshaledStringArray(ReadOnlySpan<string> inputs)
{
Expand Down
23 changes: 23 additions & 0 deletions sources/ClangSharp.Interop/Shims/MemberNotNullWhenAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information.

namespace System.Diagnostics.CodeAnalysis;

[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new[] { member };
}

public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}

public bool ReturnValue { get; }

public string[] Members { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ClangSharp.Abstractions;
internal struct FieldDesc
{
public AccessSpecifier AccessSpecifier { get; set; }
public string NativeTypeName { get; set; }
public string? NativeTypeName { get; set; }
public string EscapedName { get; set; }
public string ParentName { get; set; }
public int? Offset { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal struct FunctionOrDelegateDesc
public string EscapedName { get; set; }
public string EntryPoint { get; set; }
public string ParentName { get; set; }
public string LibraryPath { get; set; }
public string? LibraryPath { get; set; }
public string ReturnType { get; set; }
public CallingConvention CallingConvention { get; set; }
public FunctionOrDelegateFlags Flags { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal partial interface IOutputBuilder
void WriteDivider(bool force = false);
void SuppressDivider();

void WriteCustomAttribute(string attribute, Action callback = null);
void WriteCustomAttribute(string attribute, Action? callback = null);
void WriteIid(string name, Guid value);
void EmitUsingDirective(string directive);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ internal partial interface IOutputBuilder
void EndFunctionOrDelegate(in FunctionOrDelegateDesc info);

void BeginStruct(in StructDesc info);
void BeginMarkerInterface(string[] baseTypeNames);
void BeginMarkerInterface(string[]? baseTypeNames);
void EndMarkerInterface();
void BeginExplicitVtbl();
void EndExplicitVtbl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal struct ParameterDesc
public string Type { get; set; }
public string Name { get; set; }
public string NativeTypeName { get; set; }
public IEnumerable<string> CppAttributes { get; set; }
public IEnumerable<string>? CppAttributes { get; set; }
public Action<object> WriteCustomAttrs { get; set; }
public object CustomAttrGeneratorData { get; set; }
public CXSourceLocation? Location { get; set; }
Expand Down
Loading

0 comments on commit cfc66ad

Please sign in to comment.