internalsvisibleto

How to mock/isolate internal classes in VS 2012 with Fakes Framework shims?

情到浓时终转凉″ 提交于 2020-01-01 08:51:53
问题 So, the issue is that I have a bunch of internal classes in my assembly that are used by the class I want to test. Since accessors have been removed from VS2012, I'm fine with using [InternalsVisibleTo] and that works great... except when I try to shimify my internal classes, they are not visible to the Fakes framework. I should also note that the particular class I am dealing with is a static class with static methods, and I don't really want to refactor everything to use interfaces (and

How to mock/isolate internal classes in VS 2012 with Fakes Framework shims?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 08:51:15
问题 So, the issue is that I have a bunch of internal classes in my assembly that are used by the class I want to test. Since accessors have been removed from VS2012, I'm fine with using [InternalsVisibleTo] and that works great... except when I try to shimify my internal classes, they are not visible to the Fakes framework. I should also note that the particular class I am dealing with is a static class with static methods, and I don't really want to refactor everything to use interfaces (and

how can i access internals in asp.net 5

寵の児 提交于 2019-12-22 01:56:20
问题 Before asp.net 5 I would add "internalsVisibleTo(some.namespace.name)" to AssemblyInfo.cs - But I no longer have assemblyInfo.cs in my WebApi project. How do I expose internals in a WebAPI project to my unitTest project? 回答1: You can add your own AssemblyInfo.cs file. Just add a class file, name it AssemblyInfo.cs (or any name for that matter), and replace all of its code with the following line: [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("some.assembly.name")] 回答2: You can

SGEN, InternalsVisibleTo and assembly signing

寵の児 提交于 2019-12-19 04:20:40
问题 I'm trying to do something a bit unusual... I have this class Foo : public class Foo { public Foo(string name) { this.Name = name; } internal Foo() { } public string Name { get; internal set; } public int Age { get; set; } } Notice the internal setter for Name, and the internal default constructor. This would normally prevent the XML serialization, but I also marked the XML serialization assembly as "friend" with InternalsVisibleTo : [assembly: InternalsVisibleTo("TestXML2008.XmlSerializers")

InternalsVisibleTo is not working for wpf application

限于喜欢 提交于 2019-12-12 19:10:17
问题 I have the [assembly:InternalsVisibleTo("GuiAssembly")] set in the other assembly but when wpf binding occurs on a class that lives in the other assembly, it throws an exception because of the property in that class being internal. I know this works with other applications but not sure why it is not working with this particular WPF app. 回答1: I'm pretty sure that everything that WPF binds to needs to be public. 来源: https://stackoverflow.com/questions/4106721/internalsvisibleto-is-not-working

Is there a way to make Code Analysis ignore “InternalsVisibleTo”?

情到浓时终转凉″ 提交于 2019-12-11 02:36:17
问题 We have a lot of assemblies that contain internal classes which we are unit-testing by using InternalsVisibleTo to make the internal classes visible to the Unit Test assembly. This works fine, but the problem is that as soon as you use InternalsVisibleTo , it prevents the Code Analysis CA1812 warning ( Avoid uninstantiated internal classes ). It also prevents CA1811: "Avoid uncalled private code". I've done some investigation, and I've found quite a lot of unused internal classes that we

How to have “public public” v/s “internal public”? [duplicate]

心已入冬 提交于 2019-12-11 01:55:14
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: When should [assembly: InternalsVisibleTo()] be used? Access to dll methods I have two assemblies, A.dll and B.dll. A.dll has some common features, and B.dll uses it. I have to distribute A.dll and B.dll for other users eventually. However, there are some methods in A.dll that I marked as public (for use by B.dll), but I don't want anyone else to use them. Is there a good way to achieve this? Is the use of

InternalsVisibleTo causes CS0246 error: The Type or Namespace could not be found

旧街凉风 提交于 2019-12-10 09:05:41
问题 I am trying to enable one assembly to access another assembly's internal classes by adding [assembly:InternalsVisibleTo("assembly-name")] to the second assembly. However, this causes the following error: error CS0246: The type or namespace name 'InternalsVisibleTo' could not be found (are you missing a using directive or an assembly reference?) I am following the examples here: MSDN Reference What am I doing wrong? 回答1: Make sure you import System.Runtime.CompilerServices. Or use a fully