Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Update to AspNet HttpRequestHandler to use Fully Qualified Type Name (include assembly name) #1361

Merged
merged 2 commits into from
Dec 21, 2013
Merged

Update to AspNet HttpRequestHandler to use Fully Qualified Type Name (include assembly name) #1361

merged 2 commits into from
Dec 21, 2013

Conversation

jfis
Copy link
Contributor

@jfis jfis commented Dec 10, 2013

GetType was returning null when configurationBootstrapperType.Name is not in the executing assembly. Assembly, which is a required attribute in the nancyFx config section, was not actually being used. More detail here: https://groups.google.com/forum/#!topic/nancy-web-framework/nxz9Pl4EUxE

… not in the executing assembly. Assembly, which is a required attribute in the nancyFx config section, was not actually being used. More detail here: https://groups.google.com/forum/#!topic/nancy-web-framework/nxz9Pl4EUxE
@@ -37,7 +37,7 @@ private static INancyBootstrapper GetConfigurationBootstrapper()
if (configurationBootstrapperType != null)
{
var bootstrapperType =
Type.GetType(configurationBootstrapperType.Name);
Type.GetType(configurationBootstrapperType.Name + ", " + configurationBootstrapperType.Assembly);
Copy link
Member

Choose a reason for hiding this comment

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

We should use configurationBootstrapperType.AssemblyQualifiedName as that's the same thing, but without the string concatenation. Could you update it please?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, your code it correct, but could you change it to use string.Concat instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. But before I do, perhaps it's better to remove the assembly attribute and force the fully qualified type to be specified in the type attribute if needed?

ex.

<nancyFx>
  <bootstrapper type="Name.Space.Bootstrapper" assembly="Assembly.Name" />
</nancyFx>

would be

<nancyFx>
  <bootstrapper type="Name.Space.Bootstrapper, Assembly.Name" />
</nancyFx>

Copy link
Member

Choose a reason for hiding this comment

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

If we did that, then a) we would need to validate the string and throw a detailed exception if it was not in the right format and b) label it as a breaking change. It is a bit more explicit right now, because there are two fields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because assembly is not actually being used in the current code, it is not a breaking change. Type could be specified same as it is now (ex. type="Name.Space.Bootstrapper") or fully qualified (ex. type="Name.Space.Bootstrapper, Assembly.Name"). The change to the line in question would be discarded. This is how I am currently working around this issue, but with a dummy assembly attribute.
Ex.

<nancyFx>
  <bootstrapper type="Name.Space.Bootstrapper, Assembly.Name" assembly="thisIsNotUsed" />
</nancyFx>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regardless, I modified the original change to use string.Concat.

@horsdal
Copy link
Member

horsdal commented Dec 12, 2013

@jfis The second commit broke the build.You can see the build server log if you click the red cross by the commit id.

Looking through the log the brake seems to be because of this:

Errors:
/home/travis/build/NancyFx/Nancy/src/Nancy.sln (default targets) ->
(Build target) ->
/home/travis/build/NancyFx/Nancy/src/Nancy.Tests/Nancy.Tests.csproj (default targets) ->
/usr/lib/mono/4.0/Microsoft.CSharp.targets (CoreCompile target) ->  Unit/Routing/DefaultRouteResolverFixture.cs(195,37): error CS1928: Type `string' does not contain a member `ShouldContain' and the best extension method overload `Nancy.Testing.AssertExtensions.ShouldContain(this Nancy.Testing.NodeWrapper, string, System.StringComparison)' has some invalid arguments
Unit/Routing/DefaultRouteResolverFixture.cs(195,37): error CS1929: Extension method instance type `string'   cannot be converted to `Nancy.Testing.NodeWrapper'
Unit/Routing/DefaultRouteResolverFixture.cs(196,37): error CS1928: Type `string' does not contain a member `ShouldContain' and the best extension method overload `Nancy.Testing.AssertExtensions.ShouldContain(this Nancy.Testing.NodeWrapper, string, System.StringComparison)' has some invalid arguments
Unit/Routing/DefaultRouteResolverFixture.cs(196,37): error CS1929: Extension method instance type `string' cannot be converted to `Nancy.Testing.NodeWrapper'

@horsdal
Copy link
Member

horsdal commented Dec 12, 2013

A test that fails before the fix but not after would be good.

@jfis
Copy link
Contributor Author

jfis commented Dec 12, 2013

I see that it failed but I don't see how it relates to the change that was made (which was 1 line inside Hosting.AspNet). Was this test performed with any other changes to the code base? In other words, does it try to build with other changes that were applied externally to this pull request that may have happened since the original pull request, which passed? (I'm new to pull-requesting.)

@horsdal
Copy link
Member

horsdal commented Dec 12, 2013

Do those tests compile locally? Have you rebased to make sure you are up to date?

@thecodejunkie
Copy link
Member

Restarted Travis to see if it's was a Mono glitch

@jfis
Copy link
Contributor Author

jfis commented Dec 12, 2013

Is it because I didn't update my master before pushing the 2nd commit to the branch? I didn't think I had to do that since even if that is done, there's still a chance that it will be out of sync by the time the new commit is pushed. So at best it only minimizes chances (however small). That seems odd to me and would be a big problem on repos with many people pushing to master. Sorry for wasting your time. I'm new. I need to look into what rebasing does and also what happens when pull requests are tested. I'll scrap this and try again.

@horsdal
Copy link
Member

horsdal commented Dec 12, 2013

Dont scrap it @thecodejunkie's restart worked - it's green now.
Still think a test for the fix would be nice, though :)

@thecodejunkie
Copy link
Member

Yep, sometimes the Mono build on Travis doesn't play nice for what ever reason. I agree, if we could add a failing test then that would be awesome. I guess this is one of the "close to the metal" scenarios though and something like a config setting is hard to verify in a test

thecodejunkie added a commit that referenced this pull request Dec 21, 2013
…Handler

Update to AspNet HttpRequestHandler to use Fully Qualified Type Name (include assembly name)
@thecodejunkie thecodejunkie merged commit 6e13056 into NancyFx:master Dec 21, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants