-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#531: FIXED: CodeGen/Couchbase unit tests are failing for VS 16.1
- Loading branch information
Showing
5 changed files
with
131 additions
and
5 deletions.
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//----------------------------------------------------------------------------- | ||
// FILE: AppDomainExtensions.cs | ||
// CONTRIBUTOR: Jeff Lill | ||
// COPYRIGHT: Copyright (c) 2016-2019 by neonFORGE, LLC. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.Contracts; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Runtime.Serialization; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace System | ||
{ | ||
/// <summary> | ||
/// Implements <see cref="AppDomain"/> extension methods. | ||
/// </summary> | ||
public static class AppDomainExtensions | ||
{ | ||
/// <summary> | ||
/// Enumerates all non <b>System</b> and <b>Microsoft</b> assemblies currently | ||
/// loaded in the <see cref="AppDomain"/>. This can be used as a performance | ||
/// optimization when you only need to scan user assemblies. | ||
/// </summary> | ||
/// <param name="appDomain"></param> | ||
/// <returns>The enumerated assemblies.</returns> | ||
/// <remarks> | ||
/// We also use this to work around this Visual Studio bug: | ||
/// <a href="https://github.com/nforgeio/neonKUBE/issues/531"/> | ||
/// </remarks> | ||
public static IEnumerable<Assembly> GetUserAssemblies(this AppDomain appDomain) | ||
{ | ||
return appDomain.GetAssemblies() | ||
.Where(assembly => | ||
{ | ||
var fullName = assembly.FullName; | ||
if (fullName == "System" || fullName == "Microsoft") | ||
{ | ||
return false; | ||
} | ||
else | ||
{ | ||
return !(fullName.StartsWith("System.") || fullName.StartsWith("Microsoft.")); | ||
} | ||
}); | ||
} | ||
} | ||
} |
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
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,64 @@ | ||
//----------------------------------------------------------------------------- | ||
// FILE: Test_AppDomainExtensions.cs | ||
// CONTRIBUTOR: Jeff Lill | ||
// COPYRIGHT: Copyright (c) 2016-2019 by neonFORGE, LLC. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Net; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Newtonsoft; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
using Neon.Common; | ||
using Neon.Collections; | ||
using Neon.Net; | ||
using Neon.Retry; | ||
using Neon.Xunit; | ||
|
||
using Xunit; | ||
|
||
namespace TestCommon | ||
{ | ||
public class Test_AppDomainExtensions | ||
{ | ||
[Fact] | ||
[Trait(TestCategory.CategoryTrait, TestCategory.NeonCommon)] | ||
public void GetUserAssemblies() | ||
{ | ||
// Verify that we see no [System*] or [Microsoft*] related assemblies and | ||
// also that we scan types from the assemblies that are returned, to verify | ||
// that this method works around this issue: | ||
// | ||
// https://github.com/nforgeio/neonKUBE/issues/531 | ||
|
||
foreach (var assembly in AppDomain.CurrentDomain.GetUserAssemblies()) | ||
{ | ||
Assert.NotEqual("System", assembly.FullName); | ||
Assert.NotEqual("Microsoft", assembly.FullName); | ||
|
||
Assert.False(assembly.FullName.StartsWith("System.")); | ||
Assert.False(assembly.FullName.StartsWith("Microsoft.")); | ||
|
||
assembly.GetTypes().ToArray(); | ||
} | ||
} | ||
} | ||
} |