-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Return empty string in InternalAssemblyBuilder.Location #57396
Changes from 2 commits
def91f6
9bc1a72
3f1a183
5a96ce7
ce26197
d5d8ae1
8ef110f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using Xunit; | ||
|
||
namespace System.Reflection.Emit.Tests | ||
|
@@ -424,7 +423,17 @@ void Invoke_Private_SameAssembly_ThrowsMethodAccessException() | |
Assert.Throws<MethodAccessException>(() => d ()); | ||
} | ||
|
||
|
||
[Fact] | ||
public void DefineDynamicAssembly_InternalAssemblyLocationIsEmpty() | ||
{ | ||
AssemblyBuilder assembly = Helpers.DynamicAssembly(); | ||
object internalAssemblyBuilder = assembly.GetType() | ||
.GetProperty("InternalAssembly", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(assembly); | ||
object locationObj = internalAssemblyBuilder.GetType().GetProperty("Location", BindingFlags.Public | BindingFlags.Instance) | ||
.GetValue(internalAssemblyBuilder); | ||
string location = Assert.IsType<string>(locationObj); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to rewrite the test to not use private reflection? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the clue |
||
Assert.Empty(location); | ||
} | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise the assembly will get a default name
TestAssembly
and the test might succeed by accident if some other test uses the same assembly name. (Unlikely as the test would still likely do the right validation, but still)