Skip to content
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

Port DictionaryAdapter and tests to .Net Core #119

Merged
merged 31 commits into from
Dec 29, 2015

Conversation

jeremymeng
Copy link
Contributor

DictionaryAdapter Xml feature and tests are excluded as they depend on Xml features that are not available on .Net Core.

  • All tests are passing. Currently 1 test is failing. They need further investigation to either fix or disable for .Net Core
    • Fixed Some failed due to inaccessible members
    • Fixed Tests for dictionary proxy with prefixed keys
    • Fixed Resource tests failed. One is getting resource strings from .resx, the other is testing an embedded .txt file.
      • AssemblyResourceFactoryTestCase.CreateWithAbsolutePath
    • Disabled as it requires PEVerify. BaseTestCaseTestCase.TearDown_FindsVerificationErrors
    • Disabled TraceLogger listener tests are configured in App.Config. Need to find out how to do that for .Net Core.
      • TraceLoggerTests.FallUpToDefaultSource
      • TraceLoggerTests.FallUpToShorterSourceName
      • TraceLoggerTests.TracingErrorInformation
      • TraceLoggerTests.WritingToLoggerByType

@jonorossi

@jeremymeng
Copy link
Contributor Author

@jonorossi I need some help from you on the test failures, especially the first two types of failures. Thanks!

@jeremymeng
Copy link
Contributor Author

@jonorossi

I tried a hacky way (jeremymeng@0b4687c) to add trace listeners in the code since System.Configuration is not supported. But it does not match the expectation in TraceLogger.cs, specifically in Initialize() as it relies on configured trace sources: var foundSource = new TraceSource("Default", defaultLevel); at https://github.com/jeremymeng/Core/blob/0b4687cc8bf754dff6dd736bd9c467f6ffece93f/src/Castle.Core/Core/Logging/TraceLogger.cs#L153. So I disabled the tests instead.

Fixed Now with only one test failure left. I will check whether embedding .txt file is supported on .Net Core. if you think it is not worth it I can just disable it.

Thanks!

@@ -42,13 +42,19 @@ Symbol | NET35 | NET40 |
----------------------------------- | ------------------ | ------------------ | ------------------ | ------------------
`FEATURE_APPDOMAIN` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign:
`FEATURE_ASSEMBLYBUILDER_SAVE` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign:
`FEATURE_BINDINGLIST` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign:
`FEATURE_CONFIGURATION` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :no_entry_sign:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a FEATURE_SYSTEM_CONFIGURATION symbol.

@jonorossi
Copy link
Member

@jeremymeng could you provide some detail about the missing XML features in .NET Core that DictionaryAdapter is using.

#if !FEATURE_NETCORE_RESOURCE
new CustomUri("assembly://" + AssemblyName + "/CastleTests.Core.Tests.Resources.MoreRes.TestRes/content1")
#else
new CustomUri("assembly://" + AssemblyName + "/Castle.Core.Tests.Core.Tests.Resources.MoreRes.TestRes/content1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you could set the name of the resource in the project.json file? If not, then I'd prefer we rename the .NET Framework one rather than more conditional compilation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you could set the name of the resource in the project.json file?

Yes, named resources are better here. Fixed.

@@ -171,7 +175,8 @@ private object InternalGetAdapter(Type type, IDictionary dictionary, PropertyDes
}

#region Type Builders


#if FEATURE_APPDOMAIN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since .NET 4.5 has AssemblyBuilder.DefineDynamicAssembly and AssemblyBuilder.DefineDynamicModule this should be FEATURE_LEGACY_REFLECTION_API instead so we can easily drop the old code once we no longer support pre-.NET4.5. Obviously the same applies to the calling code just above here.

@jeremymeng
Copy link
Contributor Author

@jonorossi Thanks for the feedback! I will look into it today or tomorrow.

@jeremymeng
Copy link
Contributor Author

@jonorossi The change to conditionally compile on IDataErrorInfo isn't too hard (jeremymeng@6f75c96). After the change, a lot of the *Validate* types/members won't make sense any more on .Net Core, as they depend on IDataErrorInfo. I don't know the usage of these any better than you do.

@jeremymeng
Copy link
Contributor Author

@jeremymeng could you provide some detail about the missing XML features in .NET Core that DictionaryAdapter is using.

The major blocker here is the Xslt related stuffs (XsltContext)

@jonorossi jonorossi mentioned this pull request Dec 17, 2015
@jeremymeng
Copy link
Contributor Author

@jonorossi I've pushed the IDataErrorInfo change. The Xslt dependency seems non-trivial to exclude. Please let me know what you think.

@jonorossi
Copy link
Member

@jeremymeng thanks for getting the feedback addressed. I've just done another review pass and this is what is left before we can merge:

  • Remove unneeded FEATURE_NETCORE_RESOURCE from README and project.json.
  • Remove unneeded FEATURE_NETCORE_COMPONENTMODEL_API from README and project.json.
  • Change exception message in DictionaryValidateGroup.IsValid to "IDataErrorInfo is not supported on this runtime." or something rather than mentioning .NET Core because other targets can use the same code in the future.
  • We need to work out something for excluding AssemblyInfo.cs in project.json, we've always had CLS compliant defined. I'd be happy to merge the PR without it excluded (like it is in the netcore branch) with the branch not compiling and then we can work out what to do next.

@jeremymeng
Copy link
Contributor Author

@jonorossi sounds great! I've pushed the suggested changes.

The ClsCompliant issue might be related to the newly introduced XUnit shim.

jonorossi added a commit that referenced this pull request Dec 29, 2015
Port DictionaryAdapter and tests to .Net Core
@jonorossi jonorossi merged commit 7cec63e into castleproject:netcore Dec 29, 2015
@jonorossi
Copy link
Member

Thanks, merged.

I think our next step should be getting the build going:
http://builds.castleproject.org/project.html?projectId=CoreNetCore&tab=projectOverview

Looking at the CLS compliant errors from it seems unrelated to xUnit.net, this is the first compiler warning:

'ProxyGenerator' cannot be marked as CLS-compliant because the assembly does not have a CLSCompliant attribute

Also the change you made to change the unit tests to using ValidationRuleAttribute rather than the interface has broken the .NET 3.5 unit tests, I haven't had a look at why that might be.

@jeremymeng
Copy link
Contributor Author

@jonorossi Thanks!

Looking at the CLS compliant errors from it seems unrelated to xUnit.net, this is the first compiler warning:

This is a different issue than the one in the test project. I believe that both AssemblyInfo.cs files (in Castle.Core and Castle.Core.Tests projects) are generated by the non-CoreClr build so in dnx only build they don't exist yet. One possible solution is to check them in.

Also the change you made to change the unit tests to using ValidationRuleAttribute rather than the interface has broken the .NET 3.5 unit tests, I haven't had a look at why that might be.

I will take a look tomorrow.

@jonorossi
Copy link
Member

@jeremymeng ah yes you are right, I remember realising that a few weeks back and started looking at how we'd run MSBuild to generate those files before running dnu. They can't be committed because they have the version number in them.

@jeremymeng
Copy link
Contributor Author

They can't be committed because they have the version number in them.

If the files remain relatively stable (only change when version explicitly being bumped up), IMHO it is not that bad to check them in.

@jonorossi
Copy link
Member

The problem is they don't remain stable across build configurations, I just mentioned version because it was the easiest to explain. The assembly info changes for each build configuration because it changes description (the build configuration is in there so you know how the assembly you've got was built), and a bunch of other security attributes.

If we commit the files then the files cannot ever be generated otherwise it'll show up in Git with unstaged changes pending when you are working on a different build configuration. I'm happy to look at committing it with conditional compilation (i.e. extending our CommonAssemblyInfo.cs) and we get rid of the MSBuild logic.

Since this issue is merged, lets start a new issue.

@jonorossi jonorossi added this to the v4.0 milestone Jan 4, 2016
@jeremymeng
Copy link
Contributor Author

ah, I now see how the file is generated.

I'm happy to look at committing it with conditional compilation (i.e. extending our CommonAssemblyInfo.cs)

I believe it is only the [ClsCompliant(true)] entry that is needed to fix the build break. Maybe just add that to CommonAssemblyInfo.cs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants