-
Notifications
You must be signed in to change notification settings - Fork 7
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
Use ResXFileRef from this project #6
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e2f5519
Use ResXFileRef from this project. Fixes #5
bgrainger c0d8071
Test we can read file refs that we write.
farlee2121 a25bb54
Demonstate writing winforms assembly for internal ResXFileRef
farlee2121 0322c58
Move winforms type conversion to library internals
farlee2121 96dd85a
Test user-provided type converters don't break winforms overwrites
farlee2121 b13217f
Fix NullReferenceException on non-Windows platforms.
bgrainger dbb385f
Use an ordinal comparison for type names.
bgrainger daf359c
Fix tests.
bgrainger 9f99887
Switch back to C# 7.3.
bgrainger 108c4f3
Use a StringWriter instead of a temp file.
bgrainger 17a8bb4
Remove local fix for tests that breaks the build.
bgrainger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Drawing; | ||
using System.Reflection; | ||
using Xunit; | ||
|
||
namespace System.Resources.NetStandard.Tests | ||
|
@@ -18,5 +20,31 @@ public void ResxDataNode_ResXFileRefConstructor() | |
Assert.Equal(nodeName, dataNode.Name); | ||
Assert.Same(fileRef, dataNode.FileRef); | ||
} | ||
|
||
[Fact] | ||
public void ResxDataNode_CreateForResXFileRef() | ||
{ | ||
// Simulate an XML file stored in resources, which uses a ResXFileRef. The actual resx XML looks like: | ||
bgrainger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/* | ||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> | ||
<data name="Test" type="System.Resources.ResXFileRef, System.Windows.Forms"> | ||
<value>Test.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> | ||
</data> | ||
*/ | ||
var nodeInfo = new DataNodeInfo | ||
{ | ||
Name = "Test", | ||
ReaderPosition = new Point(1, 2), | ||
TypeName = "System.Resources.ResXFileRef, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", | ||
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. This TypeName could also lean on the ResXConstants value once moved. Consolidates the special strings a bit. |
||
ValueData = "TestResources/Files/Test.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8", | ||
}; | ||
var dataNode = new ResXDataNode(nodeInfo, null); | ||
var typeResolver = new AssemblyNamesTypeResolutionService(Array.Empty<AssemblyName>()); | ||
Assert.Equal("Test", dataNode.Name); | ||
Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-8"" ?> | ||
<Root> | ||
<Element>Text</Element> | ||
</Root>", dataNode.GetValue(typeResolver)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Root> | ||
<Element>Text</Element> | ||
</Root> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you move this string to
ResXConstants
?It's nice to keep all the magic strings in one place.
Also, I noticed the example Resx I made with the VS editor didn't have this whole string as it's type
Perhaps we can match on a StartsWith
System.Resources.ResXFileRef, System.Windows.Forms
(but still keep the constant inResXConstants
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.
Hmm. This also causes the namespace to change when we write the resx.