Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ ASALocalRun/

# MSBuild Binary and Structured Log
*.binlog
*.err
*.wrn

# NVidia Nsight GPU debugger configuration file
*.nvuser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace MS.Internal
using System.Runtime.InteropServices;
using System.Security;

using NativeMethods = MS.Win32.NativeMethods;

internal static partial class DpiUtil
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace MS.Internal
using System.Security;

using PROCESS_DPI_AWARENESS = MS.Win32.NativeMethods.PROCESS_DPI_AWARENESS;
using NativeMethods = MS.Win32.NativeMethods;

/// <content>
/// Contains definition of <see cref="ProcessDpiAwarenessHelper"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace MS.Internal
using System.Security;

using PROCESS_DPI_AWARENESS = MS.Win32.NativeMethods.PROCESS_DPI_AWARENESS;
using NativeMethods = MS.Win32.NativeMethods;

/// <content>
/// Contains definition of <see cref="SystemDpiHelper"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace MS.Internal
using System.Security;

using MONITOR_DPI_TYPE = MS.Win32.NativeMethods.MONITOR_DPI_TYPE;
using NativeMethods = MS.Win32.NativeMethods;

/// <content>
/// Contains definition of <see cref="WindowDpiScaleHelper"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ private static Text.TextInterface.Font GetFontFromFamily(Text.TextInterface.Font
// and at every locale name this font face has.
foreach (KeyValuePair<CultureInfo, string> name in font.FaceNames)
{
if (faceName.Equals(name.Value, StringComparison.OrdinalIgnoreCase))
if (faceName.Equals(name.Value.AsSpan(), StringComparison.OrdinalIgnoreCase))
{
return font;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ static private bool CheckContentRange(WebHeaderCollection responseHeaders, int b
// Get the instance length
// ContentRange: ZZZ
contentRangeSpan = contentRangeSpan.Slice(index + 1);
if (!contentRangeSpan.Equals("*", StringComparison.Ordinal))
if (!contentRangeSpan.Equals(Asterisk.AsSpan(), StringComparison.Ordinal))
{
// Note: for firstByteOffset and lastByteOffset, we are using Int32.Parse to make sure Int32.Parse to throw
// if it is not an integer or the integer is bigger than Int32 since HttpWebRequest.AddRange
Expand Down Expand Up @@ -891,6 +891,7 @@ static private bool CheckContentRange(WebHeaderCollection responseHeaders, int b

private const String ByteRangeUnit = "BYTES ";
private const String ContentRangeHeader = "Content-Range";
private const String Asterisk = "*";

#endregion Private Fields
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ private static byte[] GetGuidByteArray(string guidString)
{
// Make sure we have at least on '-' since Guid constructor will take both dash'ed and non-dash'ed format of GUID string
// while XPS spec requires dash'ed format of GUID
if (!guidString.Contains('-'))
if (!guidString.Contains("-"))
{
throw new ArgumentException(SR.InvalidPartName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ private CultureInfo CreateTraditionalCulture(CultureInfo numberCulture, int firs
int n = firstDigit + i - 0x10000;
twoChars[0] = (char)((n >> 10) | 0xD800); // high surrogate
twoChars[1] = (char)((n & 0x03FF) | 0xDC00); // low surrogate
digits[i] = new string(twoChars);
digits[i] = twoChars.ToString();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
</PropertyGroup>

<PropertyGroup>

<EnableDefaultItems>false</EnableDefaultItems>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
using System.Diagnostics;
using MS.Win32;

using UnsafeNativeMethods = MS.Win32.UnsafeNativeMethods;

namespace System.Windows.Input
{
//------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c

if (null != stringSource)
{
ReadOnlySpan<char> spanSource = stringSource;
ReadOnlySpan<char> spanSource = stringSource.AsSpan();
spanSource = spanSource.Trim();

int periodPos = spanSource.LastIndexOf('.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Windows.Media;
using System.Windows.Threading;
using SR = MS.Internal.PresentationCore.SR;
using UnsafeNativeMethods = MS.Win32.UnsafeNativeMethods;

namespace System.Windows.Input.StylusWisp
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using MS.Internal.PresentationCore; // SecurityHelper

using SR=MS.Internal.PresentationCore.SR;
using UnsafeNativeMethods = MS.Win32.UnsafeNativeMethods;

namespace System.Windows.Input
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using System.IO;

using SR = MS.Internal.PresentationCore.SR;
using UnsafeNativeMethods = MS.Win32.UnsafeNativeMethods;

#pragma warning disable 1634, 1691 // suppressing PreSharp warnings

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ internal void Init(object value)
else if (value is char)
{
varType = (ushort)VarEnum.VT_LPSTR;
pszVal = Marshal.StringToCoTaskMemAnsi(new String(stackalloc char[] { (char)value }));
pszVal = Marshal.StringToCoTaskMemAnsi((stackalloc char[] { (char)value }).ToString());
}
else if (type == typeof(short))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

using SR=MS.Internal.PresentationCore.SR;
using DllImport=MS.Internal.PresentationCore.DllImport;
using UnsafeNativeMethods = MS.Win32.UnsafeNativeMethods;

namespace System.Windows.Media
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace System.Windows

using SR=MS.Internal.PresentationCore.SR;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
using NativeMethods = MS.Win32.NativeMethods;

// PreSharp uses message numbers that the C# compiler doesn't know about.
// Disable the C# complaints, per the PreSharp documentation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace MS.Internal.AppModel
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
using IPersistFile = System.Runtime.InteropServices.ComTypes.IPersistFile;
using IStream = System.Runtime.InteropServices.ComTypes.IStream;
using NativeMethods = MS.Win32.NativeMethods;

#region Structs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ private static string ConvertNumberToString(int number, bool oneBased, string nu
if (number < b)
{
// Optimize common case of single-digit numbers.
return new string(stackalloc char[2] // digit + suffix
return stackalloc char[2] // digit + suffix
{
numericSymbols[number],
NumberSuffix
});
}.ToString();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ public static DllModule Load(string fileName)
// Explicitly look for module in the same directory as this one, and
// use altered search path to ensure any dependencies in the same directory are found.
_moduleHandle = Platform.LoadLibraryExW(System.IO.Path.Combine(_currentModuleDirectory, fileName), IntPtr.Zero, /* LOAD_WITH_ALTERED_SEARCH_PATH */ 8);
#if !NETSTANDARD2_0 && !NETCOREAPP2_0
#if NET
if (_moduleHandle == IntPtr.Zero)
{
try
{
try
{
// Allow runtime to find module in RID-specific relative subfolder
_moduleHandle = NativeLibrary.Load(fileName, Assembly.GetExecutingAssembly(), null);
}
}
catch (Exception) { }
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public static unsafe void SetErrorInfo(Exception ex)
{
// If the exception has information for an IRestrictedErrorInfo, use that
// as our error so as to propagate the error through WinRT end-to-end.
if (ex.TryGetRestrictedLanguageErrorObject(out var restrictedErrorObject))
if (ex.TryGetRestrictedLanguageErrorObject(out IObjectReference restrictedErrorObject))
{
using (restrictedErrorObject)
{
Expand Down Expand Up @@ -215,7 +215,7 @@ public static void ReportUnhandledError(Exception ex)
public static int GetHRForException(Exception ex)
{
int hr = ex.HResult;
if (ex.TryGetRestrictedLanguageErrorObject(out var restrictedErrorObject))
if (ex.TryGetRestrictedLanguageErrorObject(out IObjectReference restrictedErrorObject))
{
restrictedErrorObject.AsType<ABI.WinRT.Interop.IRestrictedErrorInfo>().GetErrorDetails(out _, out hr, out _, out _);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace Microsoft.Win32
using MS.Internal.PresentationFramework;
using MS.Win32;

using NativeMethods = MS.Win32.NativeMethods;

/// <summary>
/// An abstract base class for displaying common dialogs.
/// </summary>
Expand Down Expand Up @@ -80,7 +82,7 @@ public virtual Nullable<bool> ShowDialog()
// Call GetActiveWindow to retrieve the window handle to the active window
// attached to the calling thread's message queue. We'll set the owner of
// the common dialog to this handle.
IntPtr hwndOwner = UnsafeNativeMethods.GetActiveWindow();
IntPtr hwndOwner = MS.Win32.UnsafeNativeMethods.GetActiveWindow();

if (hwndOwner == IntPtr.Zero)
{
Expand Down Expand Up @@ -321,16 +323,16 @@ private void MoveToScreenCenter(HandleRef hWnd)
ref y);

// Call SetWindowPos to actually move the window.
UnsafeNativeMethods.SetWindowPos(hWnd, // handle to the window to move
NativeMethods.NullHandleRef, // window to precede this one in zorder
(int)Math.Round(x),
(int)Math.Round(y), // new X and Y positions
0, 0, // new width and height, if applicable
// Flags:
// SWP_NOSIZE: Retains current size
// SWP_NOZORDER: retains current zorder
// SWP_NOACTIVATE: does not activate the window
NativeMethods.SWP_NOSIZE | NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE);
MS.Win32.UnsafeNativeMethods.SetWindowPos(hWnd, // handle to the window to move
NativeMethods.NullHandleRef, // window to precede this one in zorder
(int)Math.Round(x),
(int)Math.Round(y), // new X and Y positions
0, 0, // new width and height, if applicable
// Flags:
// SWP_NOSIZE: Retains current size
// SWP_NOZORDER: retains current zorder
// SWP_NOACTIVATE: does not activate the window
NativeMethods.SWP_NOSIZE | NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOACTIVATE);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ internal bool MessageBoxWithFocusRestore(string message,
bool ret = false;

// Get the window that currently has focus and temporarily cache a handle to it
IntPtr focusHandle = UnsafeNativeMethods.GetFocus();
IntPtr focusHandle = MS.Win32.UnsafeNativeMethods.GetFocus();

try
{
Expand All @@ -367,7 +367,7 @@ internal bool MessageBoxWithFocusRestore(string message,
{
// Return focus to the window that had focus before we showed the messagebox.
// SetFocus can handle improper hwnd values, including null.
UnsafeNativeMethods.SetFocus(new HandleRef(this, focusHandle));
MS.Win32.UnsafeNativeMethods.SetFocus(new HandleRef(this, focusHandle));
}
return ret;
}
Expand Down Expand Up @@ -577,7 +577,7 @@ private bool HandleItemOk(IFileDialog dialog)
// When this callback occurs, the HWND is visible and we need to
// grab it because it is used for various things like looking up the
// DialogCaption.
UnsafeNativeMethods.IOleWindow oleWindow = (UnsafeNativeMethods.IOleWindow)dialog;
MS.Win32.UnsafeNativeMethods.IOleWindow oleWindow = (MS.Win32.UnsafeNativeMethods.IOleWindow)dialog;
oleWindow.GetWindow(out _hwndFileDialog);

string[] saveItemNames = _itemNames;
Expand Down Expand Up @@ -677,20 +677,20 @@ private string DialogCaption
{
get
{
if (!UnsafeNativeMethods.IsWindow(new HandleRef(this, _hwndFileDialog)))
if (!MS.Win32.UnsafeNativeMethods.IsWindow(new HandleRef(this, _hwndFileDialog)))
{
return String.Empty;
}

// Determine the length of the text we want to retrieve...
int textLen = UnsafeNativeMethods.GetWindowTextLength(new HandleRef(this, _hwndFileDialog));
int textLen = MS.Win32.UnsafeNativeMethods.GetWindowTextLength(new HandleRef(this, _hwndFileDialog));
// then make a StringBuilder...
StringBuilder sb = new StringBuilder(textLen + 1);
// and call GetWindowText to fill it up...
UnsafeNativeMethods.GetWindowText(new HandleRef(this, _hwndFileDialog),
sb /*target string*/,
sb.Capacity /* max # of chars to copy before truncation occurs */
);
MS.Win32.UnsafeNativeMethods.GetWindowText(new HandleRef(this, _hwndFileDialog),
sb /*target string*/,
sb.Capacity /* max # of chars to copy before truncation occurs */
);
// then return the results.
return sb.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
</PropertyGroup>

<PropertyGroup>

<EnableDefaultItems>false</EnableDefaultItems>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1130,8 +1130,8 @@ void FormatCollectionChangedSource(int level, object source, bool? isLikely, Lis
if (index >= 0)
{
ReadOnlySpan<char> token = aqn.AsSpan(index + PublicKeyToken.Length);
if (token.Equals(MS.Internal.PresentationFramework.BuildInfo.WCP_PUBLIC_KEY_TOKEN, StringComparison.OrdinalIgnoreCase) ||
token.Equals(MS.Internal.PresentationFramework.BuildInfo.DEVDIV_PUBLIC_KEY_TOKEN, StringComparison.OrdinalIgnoreCase))
if (token.Equals(MS.Internal.PresentationFramework.BuildInfo.WCP_PUBLIC_KEY_TOKEN.AsSpan(), StringComparison.OrdinalIgnoreCase) ||
token.Equals(MS.Internal.PresentationFramework.BuildInfo.DEVDIV_PUBLIC_KEY_TOKEN.AsSpan(), StringComparison.OrdinalIgnoreCase))
{
isLikely = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ internal bool TreeContextIsRequired
treeContextIsRequired = (_attachedPropertiesInPath > 0);

// namespace prefixes in the XPath need an XmlNamespaceManager
if (!treeContextIsRequired && HasValue(Feature.XPath) && XPath.Contains(':'))
if (!treeContextIsRequired && HasValue(Feature.XPath) && XPath.Contains(":"))
{
treeContextIsRequired = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace System.Windows.Documents
using System.Windows.Interop;
using System.Windows.Controls.Primitives;

using NativeMethods = MS.Win32.NativeMethods;

// Disable pragma warnings to enable PREsharp pragmas
#pragma warning disable 1634, 1691
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public override string[] ExtractUriFromAttr(string attrName, string attrValue)
attrName.Equals("Stroke", StringComparison.Ordinal))
{
ReadOnlySpan<char> attrValueSpan = attrValue.AsSpan().Trim();
if (attrValueSpan.StartsWith(_contextColor, StringComparison.Ordinal))
if (attrValueSpan.StartsWith(_contextColor.AsSpan(), StringComparison.Ordinal))
{
attrValueSpan = attrValueSpan.Slice(_contextColor.Length).Trim();
int spacePos = attrValueSpan.IndexOf(' ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace System.Windows.Documents
using System.Windows.Controls;
using MS.Internal.PresentationFramework;

using NativeMethods = MS.Win32.NativeMethods;

// Custom COM marshalling code and interfaces for interaction
// with the Natural Language Group's nl6 proofing engine.
internal class NLGSpellerInterop : SpellerInteropBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ internal static bool StringToInt(ReadOnlySpan<char> s, ref int i)

internal static string StringToXMLAttribute(string s)
{
if (!s.Contains('"'))
if (!s.Contains("\""))
{
return s;
}
Expand Down Expand Up @@ -3747,7 +3747,7 @@ internal Hashtable FontMappings
if (lhs_name.Length > rhs_name.Length)
{
ReadOnlySpan<char> s = lhs_name.AsSpan(0, rhs_name.Length);
if (s.Equals(rhs_name, StringComparison.OrdinalIgnoreCase))
if (s.Equals(rhs_name.AsSpan(), StringComparison.OrdinalIgnoreCase))
{
bAdd = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace System.Windows.Documents
using MS.Win32;
using System.Windows.Interop;

using NativeMethods = MS.Win32.NativeMethods;

// A Component of TextEditor supporting the default ContextMenu.
internal static class TextEditorContextMenu
{
Expand Down
Loading