Binding redirect at compile time for strong named assembly - compile-time

We have a question about assembly binding redirection at compile time:
Team V (the Veterans) is developing Product P1
P1 is continuously developed by Team V in two branches (branch 1.6.x and 1.7.x), so the version from Product P1 is incrementing over time in both branches
Team NG (New Generation) has built a Product P2 based on Product P1 (using certain assemblies from P1 branch 1.7)
Product P2 contains an Assembly A2 (strongly named) that helps implementing any Product (P2, P3...) that is based on P1
Team NG created a Nuget Package for Assembly A2 (which is referring certain assemblies from P1 branch 1.7)
Now, Team NG has started Product P3 and has to use Assembly A2 from P2 and an Assembly A1 from P1
Assembly A1 from P1 is also available as Nuget Package, but in version 1.6 (because 1.7 is not approved yet for Product P3)
So Team NG has now Product P3 with two references: A2 and A1
The problem now is, that A2 refers A1 in version 1.7 but we only have A1 in version 1.6
Team NG is not allowed to use A1 in version 1.7
This is why we are looking for a binding redirect at compile time for strongly named assemblies. As far as I know (by investigations), the 'Specific Version' property has no effect when setting this for a strongly named assembly.
Is such a redirection possible or are there any other suggestions?
Many thanks in advance
Regards, Michael

The bindingRedirect element of app.config/web.config files applies to runtime only (not compile-time).
At compile-time, the compiler does not insist on references having like version numbers, unless a reference has the SpecificVersion element set to True in a project file.
Strong-naming vs. non-strong-naming shouldn't be a factor with this.
See also How exactly does the "Specific Version" property of an assembly reference work in Visual Studio?

Related

Reformat a big C# file by order of Class Names, their properties , etc. ( need it to keep the auto generated files remain in the same order)

I tried format document but that just prettifies the code, is there a tool to reorder the appearance of the namespaces, classes, their properties in a file ( lexicographical or otherwise ) so that two autogenerated files can be textually compared to each other?
Human generated files don't have more than a class in a file, or they are hierarchical when there are many classes in the same file, so no need to resort the order of classes and their properties, but is there a tool to reformat and order a file by Class names, fields, properties, Method names and signatures?
The original problem is with updating WCF service, moves classes all over the Reference.cs file.
Edit :
To reproduce just update a WCF service and watch the Reference.cs file being completely juxtaposed, classes move up and down in the file. Trying to have a large autogenerated C# file sorted in unique way to enable textual comparison while the structure remains isomorphic to the original code.
Edit 2: Concrete example code
Suppose file is as below (psudo code)
Namespace S2
{
Class C2
Method M2
Property P2
Constructor CTOR2
Field F2
Method M1
Property P1
Field F1
Constructor CTOR1
}
Namespace S1
{
Class C1
Method M2
Property P2
Constructor CTOR2
Field F2
Method M1
Property P1
Field F1
Constructor CTOR1
}
then after sorted formatting it would be
Namespace S1
{
Class C1
Constructor CTOR1
Constructor CTOR2
Field F1
Field F2
Property P1
Property P2
Method M1
Method M2
}
Namespace S2
{
Class C2
Constructor CTOR1
Constructor CTOR2
Field F1
Field F2
Property P1
Property P2
Method M1
Method M2
}
Note : it doesnt matter what the order of properties, methods, fields are apearing, as long as after the sort they always apear in the same order.
is there a tool to reorder the appearance of the namespaces, classes,
their properties in a file ( lexicographical or otherwise ) so that
two autogenerated files can be textually compared to each other?
After spending a long time serching it, I found these:
1) Resharper extension and its Greenkeeper has stated this.
2) CodeMaid extension
But l am not sure whether these extensions meet all your requirements and if that still is not what you're looking for, I'm afraid what you want is not supported so far.
I recommend you could post a feature request in our User Voice forum(DC)----suggest a feature to share your idea.
Besides, you could share the link in this thread and anyone who is interested in this including us will vote it to get the attention of Microsoft as soon as possible.
Hope it could help you.

Unit Test a submodule static function in iOS? (Swift 4 - Xcode)

I have 4 submodules in my iOS project (Project A).
In one submodule (X Submodule) I have a class with a static function that get as input an Object defined in another submodule (Y submodule) and return a String.
How and where do I write a unit test for this static function logic? Do I write the logic in one of the App projects (A, B, C iOS Projects) that re-use those submodules (X, Y submodules)?
If you have any suggestion it will be highly appreaciated!
Just as you've created multiple frameworks for your app, you can create multiple test targets. It probably makes sense to create a test target in your X subproject that validates the X submodule.

Why are some functions available only in F# script files, not in source files?

I have noticed this a few times now. An example of an offending function is Array.take. In a script file I can write
[|1; 2; 4; 7; 6; 5|]
|> Array.take 3
|> Array.iter (printfn "%d")
and this works without a problem. But if I try to use Array.take in an actual source file, I get the following error
[|1; 2; 4; 7; 6; 5|]
|> Array.take 3 // RED SQUIGGLY ERROR HERE
|> Array.iter (printfn "%d")
and the error message is:
The value, constructor, namespace or type 'take' is not defined
So, what gives? Thanks in advance for your help.
I suspect that you're seeing this is due to different versions of F#. There was an attempt to regularise a lot of the List Seq and Array functions in F# 4.0, see: https://visualfsharp.codeplex.com/wikipage?title=Status
One of the functions that was added as part of that process was Array.take.
In F# interactive, no doubt you are using the latest version of F# but presumably you are not in your compiled project.
This could be because you haven't changed the version in the project settings or it could be because you have a nuget package attached your project which references a specific version of F# Core via nuget.
If you go to your project properties, you should see an a 'Target F# Runtime' setting, change this to F# 4.0. If I remember correctly, a nuget reference to a specific F# Core version will prevent you from changing that setting, in which case you'll need to delete the reference to F# core and re-add the correct version as a reference from the list of assemblies.

Xcode 6, iOS 8, Cocoa Touch Framework Bi directional frameworks / cyclic dependency error

My first time to post in here. Can't find any answer anywhere on my question. Please anyone:
I used earlier the iOS-Universal-Framework / fake framework to build two big frameworks, that depends of each other. So f.x. just to clarify:
Framework 1 (F1) has class A, B, C, ...
Framework 2 (F2) has class D, E, F, ...
So, what I normally did was to:
1) compile F1 with a global macro 'ENABLE_F2_METHODS_AND_TYPES' = 0
2) then moved to F2 and compiled F2 similarly with a macro 'ENABLE_F1_METHODS_AND_TYPES' = 0
Now both framework exists with class, types, etc.
3) compile F1 with macro = 1
4) compile F2 with macro = 1
That was all.
Now, the iOS-Universal-Framework is deprecated, and I have decided to move the frameworks into Cocoa Touch frameworks. So, at this moment, I have two Touch frameworks, but if I try to do similar approach, I successfully compile the two first steps, but not the third step.
I try to do some different attempts but didn't succeed.
I get the error:
Cannot find interface declaration for 'B' superclass of 'D';
so, what I tried is to add the #import "<F1/B.h>", but then get the error
Cyclic dependency in module 'F2': F2 -> F1 -> F2
How to solve this? Any other ideas?
IF succeeded, how to avoid that the frameworks is not going to be integrated into each other (Umbrella framework), but standalone frameworks. What I mean, in the
'Project' -> General -> 'Linked Frameworks and Libraries' -> I can choose "Required/Optional'.... Will that help or?
Thanks in advance.

Any benefit for targeting F# runtime for F# 4.0 or 3.1 instead of 3.0?

In Visual Studio 2015 Preview you can select from three target F# runtimes:
Is there any benefit to targeting the newer versions? Do they give you access to additional APIs? If so, which ones? It would be great if we could generate a comprehensive list.
F# Core Library Reference
Unfortunately, I don't think there is a complete list of things that you get from referencing F# 4.0. However, looking at the list of new things on CodePlex, there are a few obvious ones:
Lots of new functions in List, Seq and Array modules (so that equivalent functionality is available in all of the modules where possible)
A number of other library additions (search the table for "Library"), including things like tryUnbox, isNull, ofObj, toObj, ofNullable, toNullable but also AwaitTask for non-generic tasks
Out of the language features, the support for quoting arguments of method calls is definitely one that requires the new F# core.
Also, I'm not quite sure which of these are actually in the preview - I suspect most of them are not.
I was able to generate a complete list of new additions to the public surface area of FSharp.Core for 3.1 and 4.0. The code I used to generate the list of differences is included and can be re-purposed.
https://gist.github.com/ctaggart/0205da3f153cd20b099d
A quick-n-dirty way to see the deltas in the public surface area is to crib the code from the FSharp.Core public surface area unit tests :-)
Create a console app with below code, and rebuild/rerun it against each version you are interested in. It will dump all public APIs in that version. You can use windiff or your diff tool of choice to compare APIs between versions.
open System.Reflection
let file = typeof<int list>.Assembly.Location
let asm = Assembly.ReflectionOnlyLoadFrom(file)
let referenced = asm.GetReferencedAssemblies()
for ref in referenced do
Assembly.ReflectionOnlyLoad(ref.FullName) |> ignore
let types = asm.GetExportedTypes()
let values =
types
|> Array.collect (fun t -> t.GetMembers())
|> Array.map (fun v -> sprintf "%s: %s" (v.ReflectedType.ToString()) (v.ToString()))
|> Array.sort
|> String.concat "\r\n"
// dump to a file or print to console
printfn "%s" values

Resources