Permalink
Browse files

Restore IsVolatile (GetRequiredCustomModifiers is back in .NET Core)

  • Loading branch information...
1 parent 38fa331 commit f6ff4c0402ba81872881e1502aaa8c50de101075 Nick Craver committed May 20, 2016
Showing with 4 additions and 10 deletions.
  1. +1 −5 Sigil/Emit.LoadField.cs
  2. +1 −3 Sigil/Impl/ExtensionMethods.cs
  3. +2 −2 SigilTests/Volatile.cs
@@ -28,12 +28,8 @@ public Emit<DelegateType> LoadField(FieldInfo field, bool? isVolatile = null, in
{
throw new ArgumentException("unaligned cannot be used with static fields");
}
-
-#if COREFXTODO // see https://github.com/dotnet/corefx/issues/4543 item 3
- var useVolatile = isVolatile ?? false;
-#else
+
var useVolatile = isVolatile ?? ExtensionMethods.IsVolatile(field);
-#endif
if (!field.IsStatic)
{
@@ -21,16 +21,14 @@ public static bool StartsWithVowel(string str)
return "aeiou".IndexOf(c) != -1;
}
-
-#if !COREFXTODO // see https://github.com/dotnet/corefx/issues/4543 item 3 - would rather not offer the API than be wrong
+
public static bool IsVolatile(FieldInfo field)
{
// field builder doesn't implement GetRequiredCustomModifiers
if (field is FieldBuilder) return false;
return Array.IndexOf(field.GetRequiredCustomModifiers(), typeof(System.Runtime.CompilerServices.IsVolatile)) >= 0;
}
-#endif
public static bool IsPrefix(OpCode op)
{
@@ -20,7 +20,7 @@ class SimpleClass
public volatile int A;
#pragma warning restore CS0649
}
-#if !COREFXTODO // see https://github.com/dotnet/corefx/issues/4543 item 3
+
[TestMethod]
public void Simple()
{
@@ -35,7 +35,7 @@ public void Simple()
Assert.AreEqual(1, d1(new SimpleClass { A = 1 }));
Assert.IsTrue(instrs.Contains("volatile."));
}
-#endif
+
class NoneClass
{
public int A;

0 comments on commit f6ff4c0

Please sign in to comment.