Skip to content

Commit

Permalink
Add some missing R# annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-englert committed Jun 8, 2017
1 parent a116251 commit 91c3aa5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions TomsToolbox.Core/WeakReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private WeakReference([NotNull] SerializationInfo info, StreamingContext context
/// </summary>
/// <param name="target">The target.</param>
/// <returns>True if target is valid.</returns>
[ContractAnnotation("target: notnull => true")]
public bool TryGetTarget([CanBeNull] out T target)
{
Contract.Ensures((Contract.Result<bool>() == false) || (Contract.ValueAtReturn(out target) != null));
Expand Down
14 changes: 7 additions & 7 deletions TomsToolbox.Desktop/UserAccountControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static int LogOnInteractiveUser([NotNull] this NetworkCredential credenti
/// 0 if the function succeeds, a HRESULT of the last error if the function fails.
/// </returns>
[SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "3#")]
public static int LogOnInteractiveUser(string userName, string domain, [CanBeNull] string password, [CanBeNull] out SafeTokenHandle userToken)
public static int LogOnInteractiveUser([CanBeNull] string userName, [CanBeNull] string domain, [CanBeNull] string password, [CanBeNull] out SafeTokenHandle userToken)
{
Contract.Ensures((Contract.Result<int>() != 0) || (Contract.ValueAtReturn(out userToken) != null));

Expand Down Expand Up @@ -141,7 +141,7 @@ public static bool IsUserInAdminGroup([NotNull] SafeTokenHandle userToken)
// systems (major version >= 6) because they support linked tokens, but
// previous versions (major version < 6) do not.
var version = Environment.OSVersion.Version;

if ((version != null) && (version.Major >= 6))
{
// Running Windows Vista or later (major version >= 6).
Expand Down Expand Up @@ -216,7 +216,7 @@ public static bool IsRunAsAdmin()
using (var id = WindowsIdentity.GetCurrent())
{
var principal = new WindowsPrincipal(id);

return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
}
Expand All @@ -233,7 +233,7 @@ public static bool IsCurrentUserInGroup([CanBeNull] string groupName)
using (var id = WindowsIdentity.GetCurrent())
{
var principal = new WindowsPrincipal(id);

return principal.IsInRole(groupName);
}
}
Expand All @@ -256,7 +256,7 @@ public static bool IsUserInGroup([NotNull] SafeTokenHandle userToken, [CanBeNull
return false;

using (var id = new WindowsIdentity(token))
{
{
var principal = new WindowsPrincipal(id);
return principal.IsInRole(groupName);
}
Expand Down Expand Up @@ -437,7 +437,7 @@ public static IntPtr UacShieldIcon
SHGSI.SHGSI_ICON | SHGSI.SHGSI_SMALLICON,
ref iconInfo);

return hr != 0 ? IntPtr.Zero : iconInfo.hIcon;
return hr != 0 ? IntPtr.Zero : iconInfo.hIcon;
}
}

Expand Down Expand Up @@ -530,7 +530,7 @@ private static NetworkCredential UnpackAuthenticationBuffer([NotNull] SafeNative
};
}

private static void ParseUserDomain(ref string userName, ref string domain)
private static void ParseUserDomain([CanBeNull] ref string userName, [CanBeNull] ref string domain)
{
if (string.IsNullOrEmpty(userName))
return;
Expand Down

0 comments on commit 91c3aa5

Please sign in to comment.